Remeshing, distance to range, fast marching
// Named Arguments
auto Xh=Pch<1>(_mesh=mesh); (1)
auto u = Xh->element();
// expression handling
auto e3 = expr( "2*x*u*v:x:u:v" ); (2)
auto e3v = expr( e3, symbolExpr( "u", dxv( u ) ), symbolExpr( "v", Nx() ) );
// remeshing in seq and //
auto rm = remesh(_mesh=mesh,_params=<remeshing specs in json>); (3)
// Fast marching : compute distance to range
auto distToBoundary = distanceToRange( _space=Vh, _range=boundaryfaces( mesh ) ); (4)
auto distToBoundaryNarrowBand = (5)
distanceToRange( _space=Vh, _range=boundaryfaces( mesh ),
_max_distance=3.*mesh->hAverage() );
-
Expressivity: using our own named arguments library
-
Expressions handling: based on Ginac, handles automatic differentiation, JIT compilation
-
Remeshing in seq and parallel
-
Versatile levelset/fast marching framework
-
Narrow band FMM
Expression framework and Automatic differentiation
auto mesh = loadMesh<Mesh<Simplex<3,1>>();
auto Vh = Pch<2>( mesh ); (1)
auto u = Vh->element( inner(P()) ); (2)
auto e1 = expr( "u*u:u"); (3)
auto e2 = expr( "2*e1:e1");
auto e3base = expr( "3*e2:e2");
// handle composition
auto e3 = expr( e3base, symbolExpr("e1",e1), symbolExpr("e2",e2), symbolExpr("u",inner(P()) )); (4)
auto grad_e3 = grad<3>( e3 ); (5)
auto diff_e3_x_exact = 3*4*inner(P())*2*Px();
auto diff_e3_y_exact = 3*4*inner(P())*2*Py();
auto diff_e3_z_exact = 3*4*inner(P())*2*Pz();
auto grad_e3_exact = trans(vec(diff_e3_x_exact,diff_e3_y_exact,diff_e3_z_exact));
// compute error (machine error expected)
double error_grad_e3 = normL2(_range=elements(mesh),_expr= grad_e3 - grad_e3_exact ); (6)
-
create \$P^2_{c,h}\$
-
create an element of Vh such that \$u(x)=x^T x\$
-
create expressions
-
define symbols in expressions
-
differentiate the expressions
-
compute \$L^2\$ error norm
{feelpp} in Python
import feelpp
from feelpp.operators import *
mesh= feelpp.load(m, mesh_name, 0.1)
Xh = feelpp.functionSpace(mesh=mesh)
v=Xh.element()
v.on(range=feelpp.elements(mesh), expr=feelpp.expr("1"))
e_meas = mesh.measure()
M=mass(test=Xh,trial=Xh,range=feelpp.elements(mesh))
assert(abs(M.energy(v,v)-e_meas)<1e-10)
S=stiffness(test=Xh,trial=Xh,range=feelpp.elements(mesh))
assert(S.energy(v,v)<1e-10)
v.on(range=feelpp.elements(mesh), expr=feelpp.expr("x+y:x:y"))
assert(abs(S.energy(v,v)-2*e_meas)<1e-10)
Other Features
-
Parallel execution of toolboxes
-
Advanced multi-physics simulations
-
Advanced parametric studies including UQ
-
Reinforcement learning for micro-swimming
-
Ensemble Runs
-
Ensemble kalman filter in applications with sensors
-
{feelpp} Toolboxes in Python
import feelpp.core as fppc
from feelpp.toolboxes.core import *
from feelpp.toolboxes.fluid import *
from feelpp.toolboxes.heat import *
def simulate(toolbox, export=True, buildModelAlgebraicFactory=True,data=None):
toolbox.init(buildModelAlgebraicFactory)
#toolbox.printAndSaveInfo()
if toolbox.isStationary():
toolbox.solve()
if export:
toolbox.exportResults()
else:
if not toolbox.doRestart():
toolbox.exportResults(toolbox.timeInitial())
toolbox.startTimeStep()
while not toolbox.timeStepBase().isFinished():
if feelpp.Environment.isMasterRank():
print("time simulation: {}s/{}s with step: {}".format(toolbox.time(),toolbox.timeFinal(),toolbox.timeStep()))
toolbox.solve()
if export:
toolbox.exportResults()
toolbox.updateTimeStep()
return not toolbox.checkResults()
ht = heat(dim=3,order=1)
ok=simulate(ht)
meas = ht.postProcessMeasures().values()
df=pd.DataFrame([meas])
# do something with the pandas dataframe
....
cfd=fluid(dim=3,order=2)
ok=simulate(cfd)
....