Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding xml parsing for particles #274

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 36 additions & 9 deletions include/nektar_interface/solver_base/eqnsys_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,41 @@ class EqnSysBase : public NEKEQNSYS {

// If number of particles / number per cell was set in config; construct the
// particle system
int num_parts_per_cell, num_parts_tot;
session->LoadParameter(PartSysBase::NUM_PARTS_TOT_STR, num_parts_tot, -1);
session->LoadParameter(PartSysBase::NUM_PARTS_PER_CELL_STR,
num_parts_per_cell, -1);
this->particles_enabled = num_parts_tot > 0 || num_parts_per_cell > 0;
if (this->particles_enabled) {
this->particle_sys = std::make_shared<PARTSYS>(session, graph);
}
// int num_parts_per_cell, num_parts_tot;
// session->LoadParameter(PartSysBase::NUM_PARTS_TOT_STR, num_parts_tot,
// -1); session->LoadParameter(PartSysBase::NUM_PARTS_PER_CELL_STR,
// num_parts_per_cell, -1);
// this->particles_enabled = num_parts_tot > 0 || num_parts_per_cell > 0;
// if (this->particles_enabled) {
// this->particle_sys = std::make_shared<PARTSYS>(session, graph);
// }

/*
Particle system type is defined in the same xml document as the Nektar++
settings <NEKTAR>
...
<PARTICLES>
<INFO>
<I PROPERTY="PARTTYPE" VALUE="MyParticleSystem"/>
</INFO>
</PARTICLES>
</NEKTAR>
*/

this->particle_session = std::make_shared<ParticleReader>(session);
this->particle_session->ReadInfo();
std::string vPart = this->particle_session->GetInfo("PARTTYPE") ASSERTL0(
GetParticleSystemFactory().ModuleExists(vPart),
"ParticleSystem '" + vPart +
"' is not defined.\n"
"Ensure particle system name is correct and module is compiled.\n");
particle_sys =
GetParticleSystemFactory().CreateInstance(vPart, particle_session, graph);
particle_sys->ReadParticles();
}

ParticleReaderSharedPtr particle_session;

/// Field name => index mapper
NESO::NektarFieldIndexMap field_to_index;

Expand All @@ -64,7 +89,7 @@ class EqnSysBase : public NEKEQNSYS {
std::vector<std::string> required_fld_names;

/// Placeholder for subclasses to override; called in v_InitObject()
virtual void load_params(){};
virtual void load_params() {};

/**
* @brief Check that all required fields are defined. All fields must have the
Expand Down Expand Up @@ -127,6 +152,8 @@ class EqnSysBase : public NEKEQNSYS {

// Load parameters
load_params();

particle_system->InitObject();
}

/**
Expand Down
Loading