diff --git a/docs/_mesh/basic.md b/docs/_mesh/basic.md index e36171e..5a6c966 100644 --- a/docs/_mesh/basic.md +++ b/docs/_mesh/basic.md @@ -35,9 +35,8 @@ findnode(node); % plot indices of all vertices ``` -​ -![png]({{ site.baseurl }}/assets/images/mesh/meshbasicdoc_2_0.png) -​ +meshbasicdoc_2_0 + Apply the uniform refinement sevreal times to obtain a fine mesh. @@ -51,9 +50,8 @@ showmesh(node,elem); ``` -​ -![png]({{ site.baseurl }}/assets/images/mesh/meshbasicdoc_4_0.png) -​ + meshbasicdoc_4_0 + ## Example: A Cube in 3-D @@ -70,9 +68,8 @@ findnode3(node); ``` -​ -![png]({{ site.baseurl }}/assets/images/mesh/meshbasicdoc_6_0.png) -​ +meshbasicdoc_6_0 + Unlike the 2-D case, to apply uniform refinement to obtain a fine mesh with good mesh quality, a different ordering of the initial mesh, which may violate the positive ordering, should be used. See [3-D Red Refinement]({{ site.baseurl }}{% link _mesh/uniformrefine3.md %}). diff --git a/docs/assets/images/mesh/auxstructuredoc_13_1.png b/docs/_mesh/mesh_figures/auxstructuredoc_13_1.png similarity index 100% rename from docs/assets/images/mesh/auxstructuredoc_13_1.png rename to docs/_mesh/mesh_figures/auxstructuredoc_13_1.png diff --git a/docs/assets/images/mesh/auxstructuredoc_17_1.png b/docs/_mesh/mesh_figures/auxstructuredoc_17_1.png similarity index 100% rename from docs/assets/images/mesh/auxstructuredoc_17_1.png rename to docs/_mesh/mesh_figures/auxstructuredoc_17_1.png diff --git a/docs/assets/images/mesh/auxstructuredoc_4_0.png b/docs/_mesh/mesh_figures/auxstructuredoc_4_0.png similarity index 100% rename from docs/assets/images/mesh/auxstructuredoc_4_0.png rename to docs/_mesh/mesh_figures/auxstructuredoc_4_0.png diff --git a/docs/assets/images/mesh/auxstructuredoc_8_1.png b/docs/_mesh/mesh_figures/auxstructuredoc_8_1.png similarity index 100% rename from docs/assets/images/mesh/auxstructuredoc_8_1.png rename to docs/_mesh/mesh_figures/auxstructuredoc_8_1.png diff --git a/docs/assets/images/mesh/bddoc_11_1.png b/docs/_mesh/mesh_figures/bddoc_11_1.png similarity index 100% rename from docs/assets/images/mesh/bddoc_11_1.png rename to docs/_mesh/mesh_figures/bddoc_11_1.png diff --git a/docs/assets/images/mesh/bddoc_15_1.png b/docs/_mesh/mesh_figures/bddoc_15_1.png similarity index 100% rename from docs/assets/images/mesh/bddoc_15_1.png rename to docs/_mesh/mesh_figures/bddoc_15_1.png diff --git a/docs/assets/images/mesh/bddoc_4_0.png b/docs/_mesh/mesh_figures/bddoc_4_0.png similarity index 100% rename from docs/assets/images/mesh/bddoc_4_0.png rename to docs/_mesh/mesh_figures/bddoc_4_0.png diff --git a/docs/assets/images/mesh/bddoc_9_0.png b/docs/_mesh/mesh_figures/bddoc_9_0.png similarity index 100% rename from docs/assets/images/mesh/bddoc_9_0.png rename to docs/_mesh/mesh_figures/bddoc_9_0.png diff --git a/docs/assets/images/mesh/interfacedomain.png b/docs/_mesh/mesh_figures/interfacedomain.png similarity index 100% rename from docs/assets/images/mesh/interfacedomain.png rename to docs/_mesh/mesh_figures/interfacedomain.png diff --git a/docs/assets/images/mesh/meshbasicdoc_2_0.png b/docs/_mesh/mesh_figures/meshbasicdoc_2_0.png similarity index 100% rename from docs/assets/images/mesh/meshbasicdoc_2_0.png rename to docs/_mesh/mesh_figures/meshbasicdoc_2_0.png diff --git a/docs/assets/images/mesh/meshbasicdoc_4_0.png b/docs/_mesh/mesh_figures/meshbasicdoc_4_0.png similarity index 100% rename from docs/assets/images/mesh/meshbasicdoc_4_0.png rename to docs/_mesh/mesh_figures/meshbasicdoc_4_0.png diff --git a/docs/assets/images/mesh/meshbasicdoc_6_0.png b/docs/_mesh/mesh_figures/meshbasicdoc_6_0.png similarity index 100% rename from docs/assets/images/mesh/meshbasicdoc_6_0.png rename to docs/_mesh/mesh_figures/meshbasicdoc_6_0.png diff --git a/docs/assets/images/mesh/meshoptdoc_2_1.png b/docs/_mesh/mesh_figures/meshoptdoc_2_1.png similarity index 100% rename from docs/assets/images/mesh/meshoptdoc_2_1.png rename to docs/_mesh/mesh_figures/meshoptdoc_2_1.png diff --git a/docs/assets/images/mesh/meshoptdoc_2_2.png b/docs/_mesh/mesh_figures/meshoptdoc_2_2.png similarity index 100% rename from docs/assets/images/mesh/meshoptdoc_2_2.png rename to docs/_mesh/mesh_figures/meshoptdoc_2_2.png diff --git a/docs/assets/images/mesh/meshoptdoc_4_0.png b/docs/_mesh/mesh_figures/meshoptdoc_4_0.png similarity index 100% rename from docs/assets/images/mesh/meshoptdoc_4_0.png rename to docs/_mesh/mesh_figures/meshoptdoc_4_0.png diff --git a/docs/assets/images/mesh/meshoptdoc_7_0.png b/docs/_mesh/mesh_figures/meshoptdoc_7_0.png similarity index 100% rename from docs/assets/images/mesh/meshoptdoc_7_0.png rename to docs/_mesh/mesh_figures/meshoptdoc_7_0.png diff --git a/docs/assets/images/mesh/sc3doc_31_1.png b/docs/_mesh/mesh_figures/sc3doc_31_1.png similarity index 100% rename from docs/assets/images/mesh/sc3doc_31_1.png rename to docs/_mesh/mesh_figures/sc3doc_31_1.png diff --git a/docs/assets/images/mesh/sc3doc_34_1.png b/docs/_mesh/mesh_figures/sc3doc_34_1.png similarity index 100% rename from docs/assets/images/mesh/sc3doc_34_1.png rename to docs/_mesh/mesh_figures/sc3doc_34_1.png diff --git a/docs/assets/images/mesh/sc3doc_6_1.png b/docs/_mesh/mesh_figures/sc3doc_6_1.png similarity index 100% rename from docs/assets/images/mesh/sc3doc_6_1.png rename to docs/_mesh/mesh_figures/sc3doc_6_1.png diff --git a/docs/assets/images/mesh/scdoc_16_1.png b/docs/_mesh/mesh_figures/scdoc_16_1.png similarity index 100% rename from docs/assets/images/mesh/scdoc_16_1.png rename to docs/_mesh/mesh_figures/scdoc_16_1.png diff --git a/docs/assets/images/mesh/scdoc_17_1.png b/docs/_mesh/mesh_figures/scdoc_17_1.png similarity index 100% rename from docs/assets/images/mesh/scdoc_17_1.png rename to docs/_mesh/mesh_figures/scdoc_17_1.png diff --git a/docs/assets/images/mesh/scdoc_3_0.png b/docs/_mesh/mesh_figures/scdoc_3_0.png similarity index 100% rename from docs/assets/images/mesh/scdoc_3_0.png rename to docs/_mesh/mesh_figures/scdoc_3_0.png diff --git a/docs/assets/images/mesh/uniformrefine3doc_14_1.png b/docs/_mesh/mesh_figures/uniformrefine3doc_14_1.png similarity index 100% rename from docs/assets/images/mesh/uniformrefine3doc_14_1.png rename to docs/_mesh/mesh_figures/uniformrefine3doc_14_1.png diff --git a/docs/assets/images/mesh/uniformrefine3doc_2_0.png b/docs/_mesh/mesh_figures/uniformrefine3doc_2_0.png similarity index 100% rename from docs/assets/images/mesh/uniformrefine3doc_2_0.png rename to docs/_mesh/mesh_figures/uniformrefine3doc_2_0.png diff --git a/docs/assets/images/mesh/uniformrefine3doc_7_0.png b/docs/_mesh/mesh_figures/uniformrefine3doc_7_0.png similarity index 100% rename from docs/assets/images/mesh/uniformrefine3doc_7_0.png rename to docs/_mesh/mesh_figures/uniformrefine3doc_7_0.png diff --git a/docs/_mesh/sc.md b/docs/_mesh/sc.md index 8f8fcd3..03bb91b 100644 --- a/docs/_mesh/sc.md +++ b/docs/_mesh/sc.md @@ -5,25 +5,22 @@ sidebar: nav: mesh --- - We describe the data structure of the simplicial complex associated to a two-dimensional triangulation give by `node,elem`. The `node` records -the coordinates of vertices and `elem` is the pointer from local to -global indices of vertices. See [Basic mesh data structure]({{ site.baseurl }}{% link _mesh/basic.md %} ). +the coordinates of vertices and `elem` is the pointer from the local to +the global indices of vertices. See [Basic mesh data structure]({{ site.baseurl }}{% link _mesh/basic.md %} ). A brief summary. -- `edge`: asecond ordering, `i.e. edge(:,1) The multigrid solvers use the original ordering of `elem` obtained from either uniform refinement or bisection methods. So let `elemold=elem` before sort. +> The multigrid solvers use the original ordering of `elem` obtained from either uniform refinement or bisection methods. So let `elemold=elem` and use `elemold` in `mg`. - Examples on the usage: `PoissonRT0, PoissonBDM1` @@ -39,11 +36,10 @@ findelem(node,elem); findnode(node); ``` -![png]({{ site.baseurl }}/assets/images/mesh/scdoc_3_0.png) - +scdoc_3_0 -The basic data structure of a mesh consists of node and elem: -In iFEM, `N, NE, NT` represents the muber of vertice, edges, triangles +The basic data structure of a mesh consists of `node` and `elem`. +The integers `N, NE, NT, NE` represents the muber of vertice, edges, triangles, edges respectively. The corresponding simplicial complex consists of vertices, edges and @@ -59,37 +55,35 @@ orientation. The indexing and ordering are the combinarotry structure, i.e. only `elem` is needed, while the orientation also depends on `node`, the geometry emembdding of vertices. -For indexing, ordering and orientation, there are always local and global versions. The relation between the local and global version is the most complicated issue. +For indexing, ordering and orientation, there are always two versions: local and global. The pointer from the local and the global version is the most complicated issue. -## Indexing of Simplexes + + +## Indexing The indexing refers to the numbering of simplexes, e.g., which edge is -numbered as the first one. There are two types of the indexing: local and -global. Each simplex in the simplicial complex has a unique index which -is called the global index. In one triangle, the three vertices and three +numbered as the first one. Each simplex in the simplicial complex has a unique index which is called the global index. In one triangle, the three vertices and three edges have their local index from 1:3. In the assembling procedure of finite element methods, an element-wise -matrix using the local indexing is first computed and then assembled to get a -big matrix using the global indexing. Thus the pointer from the local -indexing to the global indexing is indispensible. For bases independent of -the ordering and orientation, e.g., `P1` and `P2` elements, this pointer -is sufficient, otherwise, the inconsistency of the local ordering/orientation -and the global ordering/orientation should be taken into account. +matrix using the local index is firstly computed and then assembled to get a +big matrix using the global index. Thus the pointer from the local +index to the global one is indispensible. For bases independent of +the ordering and orientation, e.g., `P1` and `P2` elements, the pointer of indices +is sufficient. + + + -### Indexing pointers of vertices +### Pointers of vertices -The `NT x 3` matrix `elem` is indeed the pointer from the local to the -global indices of vertices of triangles. For example `elem(t,1)=25` means -the first vertex of the triangle t is the 25-th vertex. +The `NT x 3` matrix `elem` is indeed the pointer of the vertex indices. For example `elem(t,1)=25` means the first vertex of the triangle t is the 25-th vertex. -Similiary, the `NE x 2` matrix `edge` records the pointer from the local -to the global indices of vertices of edges. +Similiary, the `NE x 2` matrix `edge` records the vertices pointer of edges. ### Local indexing of edges -The triangle constists of three vertices indexed as [1,2,3]. Each -triangle contains three edges. There are two indexing schemes for edges. +The triangle constists of three vertices indexed as `[1,2,3]` and contains three edges. Consider two local indexing schemes for those edges: * Opposite indexing `locEdge = [2,3; 3,1; 1,2]` @@ -98,83 +92,68 @@ called _opposite indexing_. * Lexicogrphic indexing `locEdgel = [1,2; 1,3; 2,3]` -In `locEdgel`, the indexing is induced from the lexicographic ordering of -the three edges. +In `locEdgel`, the indexing is induced from the lexicographic ordering of indices of the three edges. + +Note that the ordering of vertices inside one edge will not change the indexing. For example, `locEdge = [2,3; 1,3; 1,2]` use the same opposite indexing but different ordering. For the 2nd edge, choosing `[1 3]` or `[3 1]` depends on the consideration of orientation and ordering. + +For 2-D triangulations, **we shall always chose opposite indexing**. The lexicographic indexing is mainly used in the construction of `face2edge` of 3-D triangulations; see [Simplicial Complex in Three Dimensions]({{ site.baseurl }}{% link _mesh/sc3.md %}). + -For 2-D triangulations, **we shall always chose opposite indexing**. The lexicographic indexing is mainly used in the construction of `face2edge` of 3-D triangulations; see [Simplicial Complex in Three -Dimensions]({{ site.baseurl }}{% link _mesh/sc3.md %}). Note that the ordering of vertices of each edge will not change the indexing. For example, `locEdge = [2,3; 1,3; 1,2]` use the same opposite indexing but different ordering. Choosing `[1 3]` or `[3 1]` for the second edge will depend on the consideration of orientation and ordering. ### Global indexing of edges -One can easily collect all edges elementwise. The issue is the -duplication. For example, each interior edge will be counted twice. The -`unique` funciton is applied such that each edge has a unique global -index. +One can easily collect all edges elementwise. The issue is the duplication. For example, each interior edge will be counted twice. The `unique` funciton can be applied such that each edge has a unique global index. ```matlab totalEdge = uint32([elem(:,[2,3]); elem(:,[3,1]); elem(:,[1,2])]); sortedTotalEdge = sort(totalEdge,2); [edge,tempvar,je] = unique(sortedTotalEdge,'rows'); -NE = size(edge,1); ``` -### Edge pointer -`elem2edge(1:NT,1:3)` records the pointer from the local index to the -global index of edges. For example, `elem2edge(t,1)` = 10 means the first -edge of triangle `t` (which is formed by [2 3] vertices of `t`) is the -`10-th` one in the `edge` array. -Such information is stored in the third output of `unique` function. +### Pointers of edges + +`elem2edge(1:NT,1:3)` records the pointer from the local to the global index of edges. For example, `elem2edge(t,1)` = 10 means the first edge of triangle `t` (which is formed by [2 3] vertices of `t`) is the `10-th` one in the `edge` array. + +Such information is stored in the third output of `unique` function and can be reshaped to the desired size: `elem2edge = uint32(reshape(je,NT,3));` Note that the pointer `elem2edge` depends on the local indexing of edges used in the generation of `totalEdge`. Here the opposite indexing of three local edges is used. -## Ordering of Vertices -We discuss the ordering of vertices of simplexes. Again there are local -ordering and global ordering. They may not be consistent and a sign array -is used to record the inconsistency. -The local ordering refers to the ordering of local veritces of a simplex. -The local ordering could be used in the formulation of the local basis -and thus the ordering does matter. +## Ordering -The global ordering refers to the ordering of the global index of -vertices of a simplex. +We discuss the ordering of vertices of simplexes. The local and the global ordering may not be consistent and a sign array can be used to record the inconsistency. -### elem -The local ordering is always [1,2,3]. Any permutation of three -veritces of a triangle still represents the same triangle. Such -freedom provide a room to record more information like: +The local ordering refers to the ordering of local veritces. It will be used in the formulation of the local basis and thus the ordering does matter. + +The global ordering refers to the ordering of the global index of vertices. -* global ordering of vertices -* an orientation of triangles -* refinement rules +### elem +The local ordering is always `[1,2,3]`. Any permutation of three veritces of a triangle still represents the same triangle. Such freedom provide a room to record more information like: an global ordering of vertices, an orientation of triangles, and refinement rules -Two types of ordering of `elem` is of particular importance +Two types of ordering is of particular importance -* Positive ordering -* Ascend ordering +* positive ordering +* ascend ordering In the positive ordering, the three vertices are ordered such that the -signed area, det(v12,v13), is positive. If `elem` is not positive -ordered, `elem = fixorder(node,elem)` will compute the signed area by -`simplexvolume(node,elem)` and switch the vertices for triangles with -negative areas. +signed area, `det(v12,v13)`, is positive. If `elem` is not positive +ordered, `elem = fixorder(node,elem)` will compute the signed area and switch the vertices for triangles with negative areas. For 2-D triangulations, three vertices of a triangle in 2-D is sorted counter-clockwise and the first vertex is chosen as the newest vertex. -Such ordering enables the efficient implementation of local refinement +Such ordering enables the efficient implementation of the bisection refinement and coarsening in 2-D; see [Bisection in Two Dimensions]({{ site.baseurl }}{% link _afem/bisect.md %}) -and [Coarsening in Two Dimensions]({{ site.baseurl }}{% link _afem/coarsen.md %}). **Such ordering scheme -is the default choice and used in most places**. +and [Coarsening in Two Dimensions]({{ site.baseurl }}{% link _afem/coarsen.md %}). **Positive ordering is the default choice and used in most places**. -In ascend ordering, the vertices of `elem` is sorted such that +In the ascend ordering, the vertices of `elem` is sorted ascendly according to the global index of indices, i.e. elem(t,1) < elem(t,2) < elem(t,3) @@ -196,7 +175,6 @@ display('After rotation'); display(elem); display(bdFlag); 2 3 1 4 1 3 - bdFlag = 0 1 1 @@ -208,22 +186,21 @@ display('After rotation'); display(elem); display(bdFlag); 1 2 3 1 3 4 - - + bdFlag = 1 0 1 - 1 1 0 - + 1 1 0 +​ + Ascend ordering will benefit the construction of local bases for high -order basis or basis with orientation. +order Lagrange elements or in general bases with orientation dependent. -We may switch the default positive ordering of `elem` to ascend ordering +We may switch the default positive ordering of `elem` to the ascend ordering when generating data structure for finite element basis. However such -sorting is always hidden in the subroutines when a finite element basis -requiring ordering is generated; see `PoissonRT0` and `PoissonBDM1`. +sorting is always hidden inside the subroutines; see `PoissonRT0` and `PoissonBDM1`. ### edge @@ -233,57 +210,42 @@ The global ordering of edges is always ascended, i.e. edge(:,1) < edge(:,2); Indeed in the generation of `edge`, the `totalEdge` is sorted to the -ascend ordering such that `unique` can be applied to eliminate the duplication. +ascend ordering so that `unique` can be applied to eliminate the duplication. -Recall that we always use the opposite indexing of edges. For the ordering +Recall that we always use the opposite indexing of edges in two dimensions. With the same indexing, we may use - ascend ordering `[2 3; 1 3; 1 2];` - (orientation) consistent ordering `[2 3; 3 1; 1 2];` -It is consistent since the local ordering orientation of edges is -consistent with the induced orientation as the boundary of a triangle; see the -discussion on the orientation. +It is consistent since the local ordering orientation of edges is consistent with the induced orientation as the boundary of a triangle; see the discussion on the orientation. + +Even for the orientation consistent ordering, there might be an inconsistency between the local and global ordering. Namely `edge(elem2edge(t,1),1) > edge(elem2edge(t,1),2)` may happen. + -There might be an inconsistency between the local and global ordering -(even for the orientation consistent ordering). That is -`edge(elem2edge(t,1),1) > edge(elem2edge(t,1),2)` may happen. It will be more clear from the discussion of -the corresponding orientation. -## Orientation of Simplexes +## Orientation -The orientation of a triangle is either positive or negative. The -orientation of an edge is given by a tangential or normal vector. A -normal vector is obtained by rotate a given tangential vector by 90 -degree clockwise. For example, when edges are given counter-clockwise -orientation, the corresponding normal vector is the outwards normal -vector. +The orientation of a triangle is the sign of the signed area. The orientation of an edge is given by a tangential or a normal vector, which is obtained by rotate a given tangential vector by 90 degree clockwise. When edges are counter-clockwise orientated, the corresponding normal vector is the outwards normal vector. The orientation of a d-simplex will induce an orientation of its d-1 -subcomplex on the boundary and is called _the induced orientation_. For example, a positive -orientated triangle will induce the counter-clockwise orientation of its -three edges. +subcomplex on the boundary and is called *the induced orientation*. For example, a positive +orientated triangle will induce the counter-clockwise orientation of its three edges. The ordering of vertices will naturally introduce an orientation and will -be called _the ordering-orientation_. More specifically +be called *the ordering-orientation*. More specifically - The vector from `edge(:,1)` to `edge(:,2)` defines an orientation of edges. - The sign of `det(v12,v13)` defines an orientation of triangles. -The orientation of a simplex in the simplicial complex should be -uniquely determined which will be called _the global orientation_. It can be -chosen as the global ordering-orientation but not always the case. +The orientation of a simplex in the simplicial complex should be uniquely determined which will be called _the global orientation_. It can be chosen as the global ordering-orientation but not always the case. -Inside one triangle, the local orientation of three edges is more -involved. The local ordering of edges will introduce a local ordering -orientation. The orientation of the triangle will also induce an induced -orientation. The local ordering-orientation is used in the computation of -local bases and the induced orientation is used when computing the +Inside one triangle, the local orientation of three edges is more involved. The local ordering of edges will introduce a local ordering orientation. The orientation of the triangle will also induce an induced orientation. The local ordering-orientation is used in the computation of local bases and the induced orientation is used when computing the differential operator locally. They may or may not be consistent with the global orientation of edges. In general, there will be an inconsistency of the following types of -orientation and appropriate data structure should be constructed to +orientation of simplexes and appropriate data structure should be constructed to record such inconsistency. * a global orientation @@ -297,16 +259,16 @@ the global ordering-orientation, it is the sign of the signed area (output of `simplexvolume`). [Dlambda,area,elemSign] = gradbasis(node,elem); - + In the output of `gradbasis`, `area` is always positive and an additional array `elemSign` is used to record the sign of the signed area. -`Dlambda(t,:,k)` is the gradient of the barycentric coordinate $\lambda_k$. Therefore the outward normal direction of the kth face can be obtained by `-Dlambda(t,:,k)` which is independent of the ordering and orientation of triangle `t`. +`Dlambda(t,:,k)` is the gradient of the barycentric coordinate $\lambda_k$. Therefore the outward normal direction of the `k`th edge can be obtained by `-Dlambda(t,:,k)` which is independent of the ordering and orientation of triangle `t`. ### edge -For 2-D triangulations, **we shall always chose the global ordering -orientation**, i.e., from the lower index to the bigger index. +For 2-D triangulations, **we shall always chose the global ascend ordering +orientation**, i.e., from the smaller index to the bigger index. The local ordering-orientation is implicitly used when computing finite element basis in each element. For example, the edge element on edge `[i j]` @@ -318,12 +280,10 @@ Permutation of `[i j]` to `[j i]` will change the sign of the basis. Note that this is locally, i.e., element by element. The global basis associated to this edge, however, depends only on its -global orientation. We introduce `elem2edgeSign(1:NT, 1:3)` -to record the inconsistency of a local ordering-orientation and a global -orientation. +global orientation. The array `elem2edgeSign(1:NT, 1:3)` records the inconsistency of a local ordering-orientation and the global orientation. -For the consistent local ordering [2 3; 3 1; 1 2] and the global ascend -ordering-orientation, the elem2edgeSign can be generated as follows: +For the consistent local ordering `[2 3; 3 1; 1 2]` and the global ascend +ordering-orientation, the `elem2edgeSign` can be generated as follows: elem2edgeSign = ones(NT,3,'int8'); totalEdge = uint32([elem(:,[2,3]); elem(:,[3,1]); elem(:,[1,2])]); @@ -339,12 +299,12 @@ with the global orientation of edges. It depends on the ordering of `elem` and `locEdge`. When `elem` is positive ordered and `locEdge` is consistently ordered, it is. -For the ascend ordering of `elem` and `edge`, we denote the direction as +1 +In the ascend ordering of `elem` and `edge`, we denote the direction as `+1` if the direction of an edge is the same with the induced direction in a -certain elem, and -1 otherwise. Then the consistency is given by +certain elem, and `-1` otherwise. Then the consistency is given by `elem2edgeSign = [+1 -1 +1];` -The second sign is -1 because the local edge in the ascend ordering is `[1 +The second sign is `-1` because the local edge in the ascend ordering is `[1 3]` not `[3 1]`. The `elem2edgeSign` will be used when assembling differential operators. @@ -352,64 +312,75 @@ For example, when computing `div` operators on a positive orientated triangle, the edge should have outwards normal direction or equivalently the counter-clockwise orientation. + + +## Summary + We summarize the two popular ordering and orientation schemes below. -## Positive Ordering and Orientation +### Positive Ordering and Orientation -The vertices of the `elem` are sorted such that the area is always -positive. i.e. the three vertices of the elem are ordered -counter-clockwisely. Furthermore the first vertex is always the newest -vertex of the triangle for the easy of local mesh refinement and -coarsening. +The vertices of the `elem` are sorted such that the area is always positive. i.e. the three vertices of the elem are ordered counter-clockwisely. Furthermore the first vertex is always the newest vertex of the triangle for the easy of the adaptive mesh refinement (bisection) and coarsening. -The local edge is using opposite indexing and consistent ordering +The local edge is using the opposite indexing and the consistent ordering locEdge = [2,3; 3,1; 1,2] -The ascend ordering is used for global edges, i.e., `edge` is sorted s.t. +The ascend ordering is used for the global edges, i.e., `edge` is ascend sorted edge(:,1) < edge(:,2) -The inconsistency of the orientation is recorded in `elem2edgeSign`. +The inconsistency of the orientation is recorded in `elem2edgeSign` by + +```matlab +totalEdge = uint32([elem(:,[2,3]); elem(:,[3,1]); elem(:,[1,2])]); +idx = (totalEdge(:,1)>totalEdge(:,2)); +elem2edgeSign(idx) = -1; +``` **This is the default ordering and orientation scheme.** -## Ascend Ordering and Orientation -For H(curl) and H(div) elements and high order (cubic and above) H(grad) elements, we use the ascend Ordering and Orientation. +### Ascend Ordering and Orientation + +For H(curl) and H(div) elements and high order (cubic and above) H(grad) elements, we will use the ascend ordering and orientation. -*Ascend ordering*. The vertices of `elem` are sorted such that +*Ordering*. The vertices of `elem` are sorted such that elem(t,1) + ```matlab node = [0,0; 1,0; 1,1; 0,1]; % nodes elem = [2,3,1; 4,1,3]; % elements -%% -% Ascend Ordering and Orientation +%% Ascend Ordering and Orientation bdFlag = setboundary(node,elem,'Dirichlet'); [elem,bdFlag] = sortelem(elem,bdFlag); [elem2edge,edge,elem2edgeSign] = dofedge(elem); @@ -477,13 +447,14 @@ display(elem2edge); display(elem2edgeSign); ``` - + elem = 1 2 3 1 3 4 - - + + +​ edge = 1 2 @@ -491,23 +462,21 @@ display(elem2edgeSign); 1 4 2 3 3 4 - - + + +​ elem2edge = 4 2 1 5 3 2 - - + + +​ elem2edgeSign = 1 -1 1 1 -1 1 - - - -![png]({{ site.baseurl }}/assets/images/mesh/scdoc_17_1.png) - +scdoc_17_1 diff --git a/example/solver/compareMaxwellsolvers3.m b/example/solver/compareMaxwellsolvers3.m index 093d5c8..04df5e6 100644 --- a/example/solver/compareMaxwellsolvers3.m +++ b/example/solver/compareMaxwellsolvers3.m @@ -23,7 +23,7 @@ %% Lshape adaptive grids mesh.shape = 'Lshape'; mesh.type = 'adaptive'; -mesh.size = 4e4; +mesh.size = 3e4; pde = 'Maxwell'; fem = 'ND1'; % get the matrix diff --git a/solver/amgMaxwell.m b/solver/amgMaxwell.m index 245ec18..ac895b1 100644 --- a/solver/amgMaxwell.m +++ b/solver/amgMaxwell.m @@ -134,8 +134,8 @@ bdidx(isBdNode) = 1; end Tbd = spdiags(bdidx,0,N,N); -% BP = gradt*A(1:NE,1:NE)*grad + Tbd; -BP = gradt*spdiags(edgeLength.*beta,0,NE,NE)*grad + Tbd; +BP = gradt*A(1:NE,1:NE)*grad + Tbd; +% BP = gradt*spdiags(edgeLength.*beta,0,NE,NE)*grad + Tbd; %% Transfer operators between multilevel meshes setupOption.solver = 'NO';