<div dir="ltr">Dear Pestc community, <div><br></div><div>I am currently working on a 3D adaptive vector FEM solver. In my case, I need to solve two systems: one for the primal equation using a low-order discretization and another for the adjoint equation using a high-order discretization.</div><div><p>Afterward, I need to reset the section associated with the DMPlex. Whichever is set first—20 DOFs (second-order) or 6 DOFs (first-order)—the final mapping always follows that of the first-defined configuration.</p><p>Did I miss something?</p><p>Thanks, </p><p><br></p><p>Xiaodong </p></div><div><br></div><div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">PetscErrorCode DMManage::SetupSection(CaseInfo &objCaseInfo){</font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">  PetscSection s;</font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">  PetscInt     edgeStart, edgeEnd, pStart, pEnd;</font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">  PetscInt     cellStart, cellEnd;</font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">  PetscInt     faceStart, faceEnd;</font></div><font color="#000000"><br style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"></font><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">  PetscFunctionBeginUser;</font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">  DMPlexGetChart(dm, &pStart, &pEnd);</font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">  DMPlexGetHeightStratum(dm, 0, &cellStart, &cellEnd);  </font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">  DMPlexGetHeightStratum(dm, 1, &faceStart, &faceEnd);</font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">  DMPlexGetHeightStratum(dm, 2, &edgeStart, &edgeEnd); /* edges */;</font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">  PetscSectionCreate(PetscObjectComm((PetscObject)dm), &s);</font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">  PetscSectionSetNumFields(s, 1);</font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">  PetscSectionSetFieldComponents(s, 0, 1);</font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">  if (objCaseInfo.getnumberDof_local() == 6){</font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">    PetscSectionSetChart(s, edgeStart, edgeEnd);</font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">    for (PetscInt edgeIndex = edgeStart; edgeIndex < edgeEnd; ++edgeIndex) {</font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">      PetscSectionSetDof(s, edgeIndex, objCaseInfo.numdofPerEdge);</font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">      PetscSectionSetFieldDof(s, edgeIndex, 0, 1);</font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">    }</font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">  }</font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">  else if(objCaseInfo.getnumberDof_local() == 20){</font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">    PetscSectionSetChart(s, faceStart, edgeEnd);</font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">    for (PetscInt faceIndex = faceStart; faceIndex < faceEnd; ++faceIndex) {</font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">      PetscSectionSetDof(s, faceIndex, objCaseInfo.numdofPerFace);</font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">      PetscSectionSetFieldDof(s, faceIndex, 0, 1);</font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">    }  </font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">    //Test</font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">    for (PetscInt edgeIndex = edgeStart; edgeIndex < edgeEnd; ++edgeIndex) {</font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">      PetscSectionSetDof(s, edgeIndex, objCaseInfo.numdofPerEdge);</font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">      PetscSectionSetFieldDof(s, edgeIndex, 0, 1);</font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">    }</font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">  }</font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">  //</font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">  PetscSectionSetUp(s);</font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">  DMSetLocalSection(dm, s);</font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">  PetscSectionDestroy(&s);</font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000"><br></font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">  //Output map for check</font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">  ISLocalToGlobalMapping ltogm;</font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">  const PetscInt        *g_idx;</font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">  DMGetLocalToGlobalMapping(dm, &ltogm);</font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">  ISLocalToGlobalMappingView(ltogm, PETSC_VIEWER_STDOUT_WORLD); </font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">  ISLocalToGlobalMappingGetIndices(ltogm, &g_idx);</font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000"><br></font></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><span style="color:rgb(0,0,0)">  </span><span style="color:rgb(0,0,0)">PetscFunctionReturn</span><span style="color:rgb(0,0,0)">(PETSC_</span><span style="color:rgb(0,0,0)">SUCCESS);</span></div><div style="font-family:"Droid Sans Mono","monospace",monospace;font-size:14px"><font color="#000000">}</font></div></div></div>