1 #ifndef ABLATELIBRARY_PARTICLESOLVER_HPP
2 #define ABLATELIBRARY_PARTICLESOLVER_HPP
5 #include "fieldDescription.hpp"
6 #include "initializers/initializer.hpp"
7 #include "processes/process.hpp"
8 #include "solver/solver.hpp"
10 namespace ablate::particles {
16 inline static const char ParticleDiameter[] =
"ParticleDiameter";
17 inline static const char ParticleDensity[] =
"ParticleDensity";
18 inline static const char PackedSolution[] =
"PackedSolution";
19 inline static const char ParticleInitialLocation[] =
"InitialLocation";
53 std::vector<std::shared_ptr<processes::Process>>
processes;
56 std::shared_ptr<particles::initializers::Initializer>
initializer =
nullptr;
62 const std::vector<std::shared_ptr<mathFunctions::FieldFunction>>
exactSolutions;
75 ParticleSolver(std::string solverId, std::shared_ptr<domain::Region>, std::shared_ptr<parameters::Parameters> options, std::vector<FieldDescription>
fields,
76 std::vector<std::shared_ptr<processes::Process>>
processes, std::shared_ptr<initializers::Initializer>
initializer,
89 ParticleSolver(std::string solverId, std::shared_ptr<domain::Region>, std::shared_ptr<parameters::Parameters> options,
const std::vector<std::shared_ptr<FieldDescription>>&
fields,
90 std::vector<std::shared_ptr<processes::Process>>
processes, std::shared_ptr<initializers::Initializer>
initializer,
96 void Setup()
override;
99 void Initialize()
override;
133 PetscErrorCode
Save(PetscViewer viewer, PetscInt steps, PetscReal time)
override;
142 PetscErrorCode
Restore(PetscViewer viewer, PetscInt steps, PetscReal time)
override;
173 void ProjectFunction(
const std::shared_ptr<mathFunctions::FieldFunction>& fieldFunction, PetscReal time = 0.0);
196 if (field.
location == domain::FieldLocation::SOL) {
210 if (field.
location == domain::FieldLocation::SOL) {
224 const auto& field =
GetField(fieldName);
234 const auto& field =
GetField(fieldName);
252 static PetscErrorCode
ComputeParticleRHS(TS ts, PetscReal t, Vec X, Vec F,
void* ctx);
Definition: serializable.hpp:13
Definition: particleSolver.hpp:12
std::vector< std::shared_ptr< processes::Process > > processes
the processes that add source terms to the particle and domain ts
Definition: particleSolver.hpp:53
const Field & GetField(const std::string &fieldName) const
Definition: particleSolver.hpp:241
DM swarmDm
particle dm, this is a swarm
Definition: particleSolver.hpp:26
void Setup() override
Definition: particleSolver.cpp:39
void RestoreField(const std::string &fieldName, T **values)
Definition: particleSolver.hpp:233
bool dmChanged
store a boolean to state if a dmChanged (number of particles local/global changed)
Definition: particleSolver.hpp:41
std::map< std::string, Field > fieldsMap
a map of fields for easy field lookup
Definition: particleSolver.hpp:50
void StoreInitialParticleLocations()
Definition: particleSolver.cpp:205
static const char ParticleVelocity[]
Definition: particleSolver.hpp:15
void SwarmMigrate()
Definition: particleSolver.cpp:361
std::vector< FieldDescription > fieldsDescriptions
the fields specific to be created to create in the particle solver
Definition: particleSolver.hpp:44
PetscErrorCode Save(PetscViewer viewer, PetscInt steps, PetscReal time) override
Definition: particleSolver.cpp:606
void RestoreField(const Field &field, T **values)
Definition: particleSolver.hpp:209
static PetscErrorCode ComputeParticleExactSolution(TS particleTS, Vec)
Definition: particleSolver.cpp:523
std::vector< Field > fields
all fields in the particle solver
Definition: particleSolver.hpp:47
void GetField(const Field &field, T **values)
Definition: particleSolver.hpp:195
void RegisterParticleField(const FieldDescription &fieldDescriptor)
Definition: particleSolver.cpp:167
static PetscErrorCode ComputeParticleRHS(TS ts, PetscReal t, Vec X, Vec F, void *ctx)
Definition: particleSolver.cpp:495
PetscReal timeFinal
The time for uf, at the end of the advection solve.
Definition: particleSolver.hpp:35
TS particleTs
time integration data
Definition: particleSolver.hpp:29
PetscInt ndims
the dims from the subdomain
Definition: particleSolver.hpp:38
static PetscErrorCode ComputeParticleError(TS particleTS, Vec u, Vec e)
Definition: particleSolver.cpp:222
ParticleSolver(std::string solverId, std::shared_ptr< domain::Region >, std::shared_ptr< parameters::Parameters > options, std::vector< FieldDescription > fields, std::vector< std::shared_ptr< processes::Process >> processes, std::shared_ptr< initializers::Initializer > initializer, std::vector< std::shared_ptr< mathFunctions::FieldFunction >> fieldInitialization, std::vector< std::shared_ptr< mathFunctions::FieldFunction >> exactSolutions={})
Definition: particleSolver.cpp:11
TS GetParticleTS()
Definition: particleSolver.hpp:111
void ProjectFunction(const std::shared_ptr< mathFunctions::FieldFunction > &fieldFunction, PetscReal time=0.0)
Definition: particleSolver.cpp:325
void CoordinatesToSolutionVector()
Definition: particleSolver.cpp:437
const std::vector< std::shared_ptr< mathFunctions::FieldFunction > > exactSolutions
store the exact solution if provided
Definition: particleSolver.hpp:62
const std::string & GetId() const override
Definition: particleSolver.hpp:124
const std::vector< std::shared_ptr< mathFunctions::FieldFunction > > fieldInitialization
initialize other particle variables
Definition: particleSolver.hpp:59
static const char ParticleCoordinates[]
These coordinates are part of the solution vector.
Definition: particleSolver.hpp:22
const Field & GetField(const std::string &fieldName, T **values)
Definition: particleSolver.hpp:223
DM GetParticleDM()
Definition: particleSolver.hpp:105
std::shared_ptr< particles::initializers::Initializer > initializer
Store the particle location and field initialization.
Definition: particleSolver.hpp:56
void CoordinatesFromSolutionVector()
Definition: particleSolver.cpp:466
PetscErrorCode Restore(PetscViewer viewer, PetscInt steps, PetscReal time) override
Definition: particleSolver.cpp:674
virtual void MacroStepParticles(TS macroTS, bool swarmMigrate)
Definition: particleSolver.cpp:390
PetscReal timeInitial
The time for ui, at the beginning of the advection solve.
Definition: particleSolver.hpp:32
Definition: solver.hpp:17
const std::string & GetSolverId() const
Definition: solver.hpp:58
static utilities::PetscUtilities::ErrorChecker checkError
Definition: petscUtilities.hpp:46
Definition: fieldDescription.hpp:11
enum domain::FieldLocation location
The field location (sol or aux)
Definition: field.hpp:22
const std::string name
The unique name of the particle field.
Definition: field.hpp:13