How to Apply Multiple BC Types (Dirichlet, Robin, Neumann) on a Single 3D Face?
    6 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
Hello MATLAB Community,
I am trying to solve a 3D transient heat transfer problem on a simple cuboid using the PDE Toolbox.
My main challenge is applying three different types of boundary conditions to different regions of a single face.
Problem Description:
The geometry is a simple 3D block. The boundary conditions are:
- Back Face (x=0): Constant temperature (Dirichlet condition).
- All 4 Side Faces (in Y and Z): Adiabatic (zero flux / Neumann).
- Front Face (x=L): This face needs a composite boundary condition, as shown in this diagram:
- A central rectangular region with a constant temperature (Dirichlet).
- Regions above and below the central patch with convection (Robin).
- Regions to the left and right of the central patch which are adiabatic (Neumann).
What is the correct programmatic method to define these different types of boundary conditions on sub-regions of a single face, especially in a version of MATLAB that does not seem to support the more recent, flexible function handle syntaxes? 
2 Commenti
  Torsten
      
      
 il 11 Lug 2025
				I have no experience with the preprocessor of the PDE Toolbox. Usually this is done at the geometry level: either the front face of the cuboid is splitted into nine parts or the cuboid itself is created as the union of nine separate cuboids reflecting the front zones where you want to prescribe different boundary conditions.
Risposta accettata
  Torsten
      
      
 il 12 Lug 2025
        
      Spostato: Torsten
      
      
 il 12 Lug 2025
  
      gd = [3 4 -0.5 0.5 0.5 -0.5 -0.5 -0.5 0.5 0.5;
      3 4 0.5 1.5 1.5 0.5 -0.5 -0.5 0.5 0.5;
      3 4 -1.5 -0.5 -0.5 -1.5 -0.5 -0.5 0.5 0.5;
      3 4 -0.5 0.5 0.5 -0.5 0.5 0.5 2 2;
      3 4 0.5 1.5 1.5 0.5 0.5 0.5 2 2;
      3 4 -1.5 -0.5 -0.5 -1.5 0.5 0.5 2 2;
      3 4 -0.5 0.5 0.5 -0.5 -0.5 -0.5 -2 -2;
      3 4 -0.5 -1.5 -1.5 -0.5 -0.5 -0.5 -2 -2;
      3 4 0.5 1.5 1.5 0.5 -0.5 -0.5 -2 -2]';
dl = decsg(gd);  
gm = geometryFromEdges(dl);
gm = extrude(gm,0.5);
gm = mergeCells(gm,[1 2]);
gm = mergeCells(gm,[1 2]);
gm = mergeCells(gm,[1 2]);
gm = mergeCells(gm,[1 2]);
gm = mergeCells(gm,[1 2]);
gm = mergeCells(gm,[1 2]);
gm = mergeCells(gm,[1 2]);
gm = mergeCells(gm,[1 2]);
%Create the model and add the geometry
model = createpde;
model.Geometry = gm;
generateMesh(model,Hmax=0.05);
figure(1)
pdemesh(model)
specifyCoefficients(model,m=0,d=0,c=1,a=0,f=0);
applyBoundaryCondition(model,"dirichlet", ...
                             "Face",11,"u",400);
applyBoundaryCondition(model,"dirichlet", ...
                             "Face",[14 17],"u",0);
R=solvepde(model);
figure(2)
pdeplot3D(R.Mesh, ...
          ColorMapData=R.NodalSolution)
[X,Y,Z] = meshgrid(-1.5:0.05:1.5,-2:0.05:2,0:0.05:0.5);
V = interpolateSolution(R,X,Y,Z);
V = reshape(V,size(X));
%Take slice at z = zmax/2
figure(3)
Vs = slice(X,Y,Z,V,[],[],0.25);
max(Vs.CData(:))
shading interp
colorbar
3 Commenti
  Torsten
      
      
 il 12 Lug 2025
				
      Modificato: Torsten
      
      
 il 12 Lug 2025
  
			Your answer clearly solves my question, although I can't use it because of my version of matlab.
I see. "mergeCells" was introduced in R2023b - thus too recent for your MATLAB, I guess. Maybe you can read in the geometry as an stl-file or find a different solution. There should be a simpler way than what I did above. Good luck !
Più risposte (1)
  Torsten
      
      
 il 11 Lug 2025
        
      Modificato: Torsten
      
      
 il 11 Lug 2025
  
      Here is one way to create the geometry such that you can set different boundary conditions on different faces at the top.
If you consider the top as the front face, you can set e.g. Face 11 for Dirichlet, Faces 14 and 17 for Robin and Faces 16, 10, 13, 18, 12 and 15 for Neumann.
Maybe there is a simpler solution.
gd = [3 4 -0.5 0.5 0.5 -0.5 -0.5 -0.5 0.5 0.5;
      3 4 0.5 1.5 1.5 0.5 -0.5 -0.5 0.5 0.5;
      3 4 -1.5 -0.5 -0.5 -1.5 -0.5 -0.5 0.5 0.5;
      3 4 -0.5 0.5 0.5 -0.5 0.5 0.5 2 2;
      3 4 0.5 1.5 1.5 0.5 0.5 0.5 2 2;
      3 4 -1.5 -0.5 -0.5 -1.5 0.5 0.5 2 2;
      3 4 -0.5 0.5 0.5 -0.5 -0.5 -0.5 -2 -2;
      3 4 -0.5 -1.5 -1.5 -0.5 -0.5 -0.5 -2 -2;
      3 4 0.5 1.5 1.5 0.5 -0.5 -0.5 -2 -2]';
dl = decsg(gd);  
gm = geometryFromEdges(dl);
gm = extrude(gm,0.5);
%Create the model and add the geometry
model = createpde;
model.Geometry = gm;
generateMesh(model);
pdegplot(model,"FaceAlpha",0.3)
hold on
pdemesh(model)
pdegplot(gm,"FaceLabels","on")
3 Commenti
Vedere anche
Categorie
				Scopri di più su Geometry and Mesh in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!






