Creating a new example - dbcavalcanti/porousLab GitHub Wiki
How to Create an Example in PorousLab
The PorousLab framework is designed for object-oriented simulation of porous media problems. A simulation follows a well-defined workflow involving two main objects:
mdl
: the model object (geometry, materials, boundary conditions)anl
: the analysis object (solver settings, execution)
General Workflow
Algorithm: Setting up an example in PorousLab
1. Create and configure the model object (mdl):
a. Instantiate the appropriate model class
(e.g., Model_H, Model_M, Model_HM)
b. Load or generate mesh data: node, elem
c. Set the mesh using: mdl.setMesh(node, elem)
d. Define and configure material objects
(e.g., PorousMedia, Fluid)
e. Assign materials to the model: mdl.setMaterial(...)
f. Apply boundary and initial conditions
2. Create and configure the analysis object (anl):
a. Instantiate analysis class
(e.g., Anl_Linear, Anl_Transient)
b. Set solver parameters (e.g., time step, tolerances)
3. Run the simulation:
anl.run(mdl)
4. Post-process the results:
Use built-in tools such as:
- mdl.plotField('variable')
- mdl.plotFieldAlongSegment(...)
- mdl.plotDeformedMesh(...)
Pre-processing
Mesh Generation
PorousLab uses:
NODE
: an[nNodes x 2]
matrix with node coordinatesELEM
: a{nElem x 1}
cell array with element connectivity
Meshes can be:
- Generated internally with
regularMesh(...)
- Imported from external tools such as Gmsh using this converter
Assign mesh to the model with:
mdl.setMesh(node, elem);
Boundary Conditions
You can apply Dirichlet and Neumann BCs in three ways:
- At node:
setDirichletBCAtNode
,setNeumannBCAtNode
- At point:
setDirichletBCAtPoint
,setNeumannBCAtPoint
- At border:
setDirichletBCAtBorder('left')
, etc.
Physics-specific methods like:
setPressureDirichletBCAtNode
setDisplacementDirichletBCAtBorder
Post-processing
Visualization is done through FEMPlot
methods:
plotField('pressure')
: scalar field contourplotFieldAlongSegment(p1, p2, 'pressure')
: profile plotplotDeformedMesh(scale)
: view deformed configuration (mechanics)
Textual outputs:
printResults()
: print nodal resultsprintResultsHeader()
: customize variable labels