Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bulk penalty stab div #102

Open
wants to merge 34 commits into
base: bulk_penalty_stab
Choose a base branch
from

Conversation

amartinhuertas
Copy link
Member

@amboschman ... Mostly creating this PR so that I can add comments to the code

not to be merged YET .... WIP

amboschman and others added 27 commits November 7, 2024 11:29
…st_agg_cells_rhs_contribs). Fix with rank does not seem to work.
…as this has been fixed by changing the BulkGhostPenaltyAssembleRhsMap.
What I said is, take a function u_ex such that div(u_ex) in Q_BB
And check that the stab term is zero
E.g, u = (x,y), its div(u) is a constant
Then, you must get zero
…h behaviour,

i.e., with u_ex and p_ex in FE spaces, eps for both; if only uex in FE space, eps only for u.
@amartinhuertas amartinhuertas self-assigned this Jan 24, 2025
### STABILIZATION ON Ωagg\Troot ###
###########################################

## (1) FIND ALL INTERIOR CELLS WHICH ARE NOT PART OF AN AGGREGATE
Copy link
Member Author

@amartinhuertas amartinhuertas Jan 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amboschman ... I have taken a careful look at the lines below this one till the call to revised_setup_aggregate_to_cut_cells. I think I also got what the issue/bug with your original setup_aggregate_to_cut_cells was. At the end of the day, you need to generate an array with the root_cells and an array with the cut_cells in the very same order you have them listed in aggregate_to_cells

In any case, I think there is a better (more general and more efficient) way to do the very same thing. I copy and paste the code that implements this alternative way below:

# Set up bg_cell_type
# -1: exterior 
#  0: cut 
#  1: interior, non root 
# >1: interior root 

# TO-DO: pack this for loop in a function `set_up_cell_type`
cell_type = zeros(Int64,length(aggregates))
for (pos,val) in enumerate(aggregates)
   if val==0
      cell_type[pos]=-1
   else 
      cell_type[val]+=1
   end
end

cell_is_exterior(cell)=cell_type[cell]==-1
cell_is_cut(cell)=cell_type[cell]==0
cell_is_interior_root(cell)=cell_type[cell]>1
cell_is_interior_non_root(cell)=cell_type[cell]==1
 
function flatten(array_of_arrays)
   vcat(array_of_arrays...)
end

function restrict_to_cell_type(aggregate_to_cells, cell_type_filter)
    ret=Vector{Int}[]
    for agg in aggregate_to_cells
      new_agg=Int64[]
      for cell in agg
         if cell_type_filter(cell)
            push!(new_agg, cell)
         end 
      end 
      push!(ret, new_agg)
    end
    ret
end 

With this machinery, you can compute root_cells, cut_cells and aggregate_to_cut_cells in a unified way as:

root_cells = flatten(restrict_to_cell_type(aggregate_to_cells,cell_is_interior_root))
aggregate_to_cut_cells = restrict_to_cell_type(aggregate_to_cells,cell_is_cut))
cut_cells   = flatten(aggregate_to_cut_cells)

Let me know if that makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants