How to pass parameters in user defined function in applyBound​aryConditi​on()?

2 views (last 30 days)
What I want to do:
Create a time dependent geometry changing at every iteration, mesh it, solve a pde with time dependent boundary condtions and repeat
What I tried:
Method 1:
  1. initialize
  2. for t = 0:delta_t:t_final:
  3. update geometry by geometryFromMesh(..)
  4. generateMesh
  5. apply boundary condtion
  6. condtion is parameter dependent, can't pass my parameter in my custom function in thermalBC(model, Face, --, HeatFlux, @externalHeatFlux) (thermalBC is similar to applyBoundaryCondition)
  7. solve pde for single instance
  8. repeat
Q1. How can I pass a parameter in my function @externalHeatFlux to be used in thermalBC(model, Face, --, HeatFlux, @externalHeatFlux)?
Essentially I want to pass the parameter 'time' because the heat source is time dependent. But you can say state.time is automatically passed in this function (explained in documentation of thermalBC)
I don't want to go this way because:
Method 2:
  1. Initialize, make geometry, mesh, applyBC using state.time as passed default
  2. set tlist = [0:delta_t:t_final)
  3. then later use solve(thermalmodel, tlist)
  4. can't change the geometry! Because solve(..) solves for whole duration considering same geometry.
Q2. Can I update geometry somehow so that I solve the pde step by step, not in one shot like solve(model, tlist). This method inherently assumes that geometry will be the same.
I am confused between using solve(model, t_list) to solve for all time instance, and using changing geometry with simple loops.
I would personally prefer a solution helping in method 1 because that looks more systematic and clean. Someone working with pdes can look into it and help! I would be grateful.
Thanks in advance.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!