11 Fixed boundary conditions
13 Impose fixed boundary conditions within an action set. Such an action set
14 can be injected into each and every grid sweep.
15 @ref swift_boundary_conditions "Swift's generic boundary condition"
16 remarks discuss this realisation variant. It is quite heavy-weight and can
17 yield invalid states prior to the very first time step.
19 The action set is used by adding it after you have lowered the Swift 2
20 formalism into a Peano 4 project:
22 ~~~~~~~~~~~~~~~~~~~~~~~~~
23project.additional_action_sets_per_solver_step.append(
24 swift2.api.boundaryconditions.Fixed(particle_set=particle_set,
25 damp_particles_as_they_approach_boundary=True
28 ~~~~~~~~~~~~~~~~~~~~~~~~~
30 @param particle_set: swift2.particle.Particle
31 The particle set for which we implement the boundary conditions.
33 @param relative_domain_halo: Positive float smaller than 0.5
34 The relative boundary in which we actually check particles at
35 all. This one refers to the cells adjacent to the boundary. So
36 if you pass in a 0.1, it means that 10% of this cell will next
37 to the boundary will actually be read as "on the boundary".
39 @param damp_particles_as_they_approach_boundary: Boolean
45 relative_domain_halo=0.1
49 Fixed boundary condition
51 Fixed boundary conditions are very difficult to impose within SPH. This
52 is a very simplistic realisation of fixed boundary conditions, where
53 particles are forced to come to rest once they approach the domain
59 self.
d[
"PARTICLE"] = particle_set.particle_model.name
60 self.
d[
"PARTICLES_CONTAINER"] = particle_set.name
61 self.
d[
"VELOCITY_ATTRIBUTE"] = particle_set.particle_model.velocity.get_accessor_name()
62 self.
d[
"RELATIVE_DOMAIN_HALO"] = relative_domain_halo
65 return __name__.replace(
".py",
"").replace(
".",
"_")
67 __Template_TouchVertexLastTime = jinja2.Template(
69 // check only boundary vertices
70 if (::swift2::boundaryconditions::isVertexOnGlobalBoundary(marker,DomainOffset,DomainSize)) {
71 for (auto& particle: fineGridVertex{{PARTICLES_CONTAINER}}) {
72 ::swift2::boundaryconditions::applyFixedBoundaryCondition(
77 {{RELATIVE_DOMAIN_HALO}},
80 } // for loop over particles
87 if operation_name == ActionSet.OPERATION_TOUCH_VERTEX_LAST_TIME:
95 result = jinja2.Template(
98#include "vertexdata/{{PARTICLES_CONTAINER}}.h"
99#include "globaldata/{{PARTICLE}}.h"
100#include "swift2/kernels/ParticleSetIterators.h"
101#include "swift2/boundaryconditions/Utils.h"
102#include "swift2/boundaryconditions/FixedBoundary.h"
105 return result.render(**self.
d)
111 _spacetreeId = treeNumber;
Action set (reactions to events)
Fixed boundary conditions.
__Template_TouchVertexLastTime
get_constructor_body(self)
Define a tailored constructor body.
get_attributes(self)
Return attributes as copied and pasted into the generated class.
__init__(self, particle_set, relative_domain_halo=0.1)
Fixed boundary condition.
get_action_set_name(self)
Return unique action set name.
get_includes(self)
Return include statements that you need.
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.
user_should_modify_template(self)
Is the user allowed to modify the output.