# Request for help on DDM method for handling vector fields

**URL:** https://community.freefem.org/t/request-for-help-on-ddm-method-for-handling-vector-fields/3566
**Category:** General Discussion
**Created:** [October 27, 2024, 10:17am UTC](https://community.freefem.org/t/request-for-help-on-ddm-method-for-handling-vector-fields/3566 "2024-10-27T10:17:05Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![qingYang](https://avatars.discourse-cdn.com/v4/letter/q/9f8e36/32.png) [@qingYang](https://community.freefem.org/u/qingYang)
#### Post date: [October 27, 2024, 10:17am UTC](https://community.freefem.org/t/request-for-help-on-ddm-method-for-handling-vector-fields/3566/1 "2024-10-27T10:17:05Z")

</div>

Dear Professor and FreeFem users:  
I want to use the DDM method to solve three-dimensional electromagnetic field problems. Before solving, some preprocessing is needed, such as adding layers and smoothing (as shown in the program below). However, in the case, it is a scalar field definition. If I want to solve a three component vector field, what approach should I follow to conduct the research? Are there any more cases? This problem has been bo  
[Addlayers.edp](https://community.freefem.org/uploads/short-url/mYUbMMdTSfanW6zwikKCy249hIf.edp) (542 Bytes)  
thering me for a long time. I hope to receive your help and provide some ideas. Thank you.

---

<div class="post-metadata">

### Author: ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)
#### Post date: [October 27, 2024, 11:53am UTC](https://community.freefem.org/t/request-for-help-on-ddm-method-for-handling-vector-fields/3566/2 "2024-10-27T11:53:55Z")

</div>

Why would you want to do this yourself instead of using the available tools and macros?

---

<div class="post-metadata">

### Author: ![qingYang](https://avatars.discourse-cdn.com/v4/letter/q/9f8e36/32.png) [@qingYang](https://community.freefem.org/u/qingYang)
#### Post date: [October 27, 2024, 12:24pm UTC](https://community.freefem.org/t/request-for-help-on-ddm-method-for-handling-vector-fields/3566/3 "2024-10-27T12:24:43Z")

</div>

Dear professor, thank you very much for your reply. I haven’t been exposed to this content very much. This is a part of the program that my classmates shared with me, so I didn’t notice that there were ready-made tools available for use as I was studying. Could you please recommend some keywords or links related to this toolbox for me? I would like to further my studies and express my gratitude to you once again

---

<div class="post-metadata">

### Author: ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)
#### Post date: [October 27, 2024, 12:42pm UTC](https://community.freefem.org/t/request-for-help-on-ddm-method-for-handling-vector-fields/3566/4 "2024-10-27T12:42:09Z")

</div>

This is just some examples [https://www.youtube.com/watch?v=-Aw2O46V2bo](https://www.youtube.com/watch?v=-Aw2O46V2bo) or [http://joliv.et/FreeFem-tutorial/main.pdf](http://joliv.et/FreeFem-tutorial/main.pdf), there is many content available, you should not do this yourself if you are already having trouble for this very basic step.

---

<div class="post-metadata">

### Author: ![qingYang](https://avatars.discourse-cdn.com/v4/letter/q/9f8e36/32.png) [@qingYang](https://community.freefem.org/u/qingYang)
#### Post date: [October 27, 2024, 12:45pm UTC](https://community.freefem.org/t/request-for-help-on-ddm-method-for-handling-vector-fields/3566/5 "2024-10-27T12:45:58Z")

</div>

Dear Professor, thank you very much for your reply and suggestions

---

<div class="post-metadata">

### Author: ![qingYang](https://avatars.discourse-cdn.com/v4/letter/q/9f8e36/32.png) [@qingYang](https://community.freefem.org/u/qingYang)
#### Post date: [November 1, 2024, 2:57pm UTC](https://community.freefem.org/t/request-for-help-on-ddm-method-for-handling-vector-fields/3566/6 "2024-11-01T14:57:01Z")

</div>

Dear professor, thank you very much for your suggestion last time. With your advice, I have successfully calculated the scalar field (temperature field) correctly.  
I am currently trying a new problem and encountering issues.  
(1) Goal: My goal is to use the ffddm tool to calculate 3D electromagnetic fields using A&phi method. Manuscript Program (DDM\_help. edp)  
(2) Question: Since A exists in the entire domain Th, while V only exists in ThC, and Th3=trunc (Th, sgm\>1), this will lead to a problem where in:  
macro Varf (varfName, meshName, VhName), meshName and VhName are not the same. Should I address this issue? If possible, please provide some examples.  
Thank you for your help time and time again. Wishing you a happy life!  
[GetMesh.idp](https://community.freefem.org/uploads/short-url/w7k4JepOHYVjWotytow8aiUEMwE.idp) (7.0 KB)  
[DDM\_help.edp](https://community.freefem.org/uploads/short-url/e4ASzZmqewm7aSZvDrtwozRwn81.edp) (6.6 KB)

---

<div class="post-metadata">

### Author: ![phtournier](https://avatars.discourse-cdn.com/v4/letter/p/3da27b/32.png) [@phtournier](https://community.freefem.org/u/phtournier)
#### Post date: [November 4, 2024, 1:05pm UTC](https://community.freefem.org/t/request-for-help-on-ddm-method-for-handling-vector-fields/3566/7 "2024-11-04T13:05:44Z")

</div>

Can you share a sequential version of your code that solves your EM problem with the A&phi method, so that we can look into the best way to help you parallelize it using DD ?

---

<div class="post-metadata">

### Author: ![qingYang](https://avatars.discourse-cdn.com/v4/letter/q/9f8e36/32.png) [@qingYang](https://community.freefem.org/u/qingYang)
#### Post date: [November 4, 2024, 1:17pm UTC](https://community.freefem.org/t/request-for-help-on-ddm-method-for-handling-vector-fields/3566/8 "2024-11-04T13:17:58Z")

</div>

thank you very much for your reply. The brief statement of sequential version is as follows ,I would like to know how to use the ffddm tool to implement DDM and parallelism. Looking forward to your reply.  
[DDM\_mine.edp](https://community.freefem.org/uploads/short-url/xESntvn1zUQS29cg5xsISdpLXZM.edp) (2.1 KB)

---

<div class="post-metadata">

### Author: ![qingYang](https://avatars.discourse-cdn.com/v4/letter/q/9f8e36/32.png) [@qingYang](https://community.freefem.org/u/qingYang)
#### Post date: [November 4, 2024, 1:20pm UTC](https://community.freefem.org/t/request-for-help-on-ddm-method-for-handling-vector-fields/3566/9 "2024-11-04T13:20:35Z")

</div>

This is my first attempt to refer to some manuals, and I hope to receive your help and advice  
[try\_help.edp](https://community.freefem.org/uploads/short-url/7Gv2J0qg68I4fZoRpoJhLO23BbN.edp) (7.3 KB)

---

<div class="post-metadata">

### Author: ![qingYang](https://avatars.discourse-cdn.com/v4/letter/q/9f8e36/32.png) [@qingYang](https://community.freefem.org/u/qingYang)
#### Post date: [November 6, 2024, 2:23pm UTC](https://community.freefem.org/t/request-for-help-on-ddm-method-for-handling-vector-fields/3566/10 "2024-11-06T14:23:24Z")

</div>

Dear teacher, I have studied your video on YouTube, but I still haven’t solved this problem well. Can you give me further advice。

---

<div class="post-metadata">

### Author: ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)
#### Post date: [November 6, 2024, 2:46pm UTC](https://community.freefem.org/t/request-for-help-on-ddm-method-for-handling-vector-fields/3566/11 "2024-11-06T14:46:25Z")

</div>

Well, the video gives an introduction to PETSc, but you tried to use ffddm, so there is not much I can do.

---

<div class="post-metadata">

### Author: ![phtournier](https://avatars.discourse-cdn.com/v4/letter/p/3da27b/32.png) [@phtournier](https://community.freefem.org/u/phtournier)
#### Post date: [November 6, 2024, 5:04pm UTC](https://community.freefem.org/t/request-for-help-on-ddm-method-for-handling-vector-fields/3566/12 "2024-11-06T17:04:06Z")

</div>

Here is your code rewritten using the composite FE spaces formalism (see [Composite finite element spaces NEW!](https://doc.freefem.org/documentation/composite.html)) allowing variational forms with coupled variables living on different meshes. The problem is solved with PETSc using a fieldsplit preconditioner, with a simple block preconditioner using hpddm on the A and V blocks.  
Are you trying to test specific domain-decomposition methods for your problem, or do you simply want to accelerate your code ?  
[try\_help.edp](https://community.freefem.org/uploads/short-url/mUca4pFOCdlFEC7688lQI4B5BXv.edp) (5.6 KB)

---

<div class="post-metadata">

### Author: ![qingYang](https://avatars.discourse-cdn.com/v4/letter/q/9f8e36/32.png) [@qingYang](https://community.freefem.org/u/qingYang)
#### Post date: [November 6, 2024, 11:20pm UTC](https://community.freefem.org/t/request-for-help-on-ddm-method-for-handling-vector-fields/3566/13 "2024-11-06T23:20:08Z")

</div>

Thank you for your reply. I previously used matrix block mode, and KK = [[AA, AV],  
[VA, VV]];has already solved the task of solving A and V. At present, what I want to do is to use region decomposition and conduct some other research in each subdomain. I used the ffddm method for this idea (new manuscript new1. edp), but in the ffddm tool, there is only one definition for Varfmesh and Vhname. I used the sgm parameter to constrain the region of V, but there have been errors.  
[new1.edp](https://community.freefem.org/uploads/short-url/rrq6mLrtzYEOu4wsbCFL3HP1tv3.edp) (7.3 KB)

---

<div class="post-metadata">

### Author: ![qingYang](https://avatars.discourse-cdn.com/v4/letter/q/9f8e36/32.png) [@qingYang](https://community.freefem.org/u/qingYang)
#### Post date: [November 6, 2024, 11:20pm UTC](https://community.freefem.org/t/request-for-help-on-ddm-method-for-handling-vector-fields/3566/14 "2024-11-06T23:20:44Z")

</div>

Thank you for your reply.Professor, I will continue to delve deeper into my studies.
