This is the main class of this project. More...
#include <PhysicalModel.h>
Public Member Functions | |
properties general manipulation | |
const std::string | getName () const |
Return the name of the physical model. More... | |
void | setName (const std::string) |
set the name of the physical model More... | |
Properties * | getProperties () |
get all properties (beware of what you do with them!): please consider calling setModified(). More... | |
bool | isModified () |
check if something have changed More... | |
void | setModified () |
tell the physical model something has changed (for example: a property was modified/added). More... | |
export to files | |
void | xmlPrint (std::ostream &o, bool opt=false) |
print the physical model to an output stream in a XML format (see physicalmodel.xsd for detail about the XML format). More... | |
void | exportPatran (std::string filename) |
Save the geometry (atoms/cells) of this PhysicalModel in the Patran format. More... | |
void | exportAnsysMesh (std::string filename) |
Save the mesh (atoms/cells) of this PhysicalModel in the Ansys format. More... | |
constructors and destructors. | |
static const char * | VERSION |
Current PML library version. More... | |
PhysicalModel () noexcept | |
Default constructor : this one just initialize everything. More... | |
PhysicalModel (const char *fileName, PtrToSetProgressFunction pspf=nullptr) | |
instantiate a physical model object using a XML native format file This method may throw a PMLAbortException if a problem occurs. More... | |
virtual | ~PhysicalModel () |
destructor More... | |
component manipulations | |
unsigned int | getNumberOfExclusiveComponents () const |
get the total number of exclusive components More... | |
unsigned int | getNumberOfInformativeComponents () const |
get the total number of informative components More... | |
unsigned int | getNumberOfAtoms () const |
get the number of atoms More... | |
unsigned int | getNumberOfCells () const |
get the total nr of cell in the physical model (exclusive as well as informative) More... | |
Component * | getExclusiveComponent (const unsigned int) const |
get an exclusive component by its index in the list More... | |
void | setExclusiveComponents (MultiComponent *) |
set the exclusive multi component. Becareful: the physical model takes control of this MultiComponent More... | |
MultiComponent * | getExclusiveComponents () const |
get all the exclusive components More... | |
MultiComponent * | getInformativeComponents () const |
get all the informative components More... | |
StructuralComponent * | getAtoms () const |
get all the atoms More... | |
Component * | getInformativeComponent (const unsigned int) const |
get an informative component by its index in the list More... | |
void | setInformativeComponents (MultiComponent *) |
set the exclusive multi component. Becareful: the physical model takes control of this MultiComponent More... | |
void | setAtoms (StructuralComponent *, bool deleteOld=true) |
set the atom structural component. More... | |
bool | addAtom (Atom *) |
Add a new atom to the atoms' structural component. More... | |
Atom * | getAtom (const unsigned int id) |
Get the atom that has the global index given in parameters. More... | |
bool | addGlobalIndexAtomPair (std::GlobalIndexStructurePair) |
add or update a pair to the atom map. More... | |
bool | addGlobalIndexCellPair (std::GlobalIndexStructurePair) |
add or update a pair to the cell map. More... | |
Cell * | getCell (const unsigned int id) |
get the cell that has the global index given in parameters. More... | |
Structure * | getStructureByName (const std::string n) |
get a cell using its name More... | |
Component * | getComponentByName (const std::string n) |
get a structural or multi component by its name. More... | |
virtual void | setProgress (const float donePercentage) |
this method is called during a long process everytime a little bit of the process is finished. More... | |
virtual void | setAtomPosition (Atom *atom, const double pos[3]) |
Set the new position of an atom. More... | |
double * | getPositionPointer () const |
get the pointer to the memory space allocated for the atom's position. More... | |
double * | getPositionPointer (const unsigned int index) const |
get the pointer to the memory space allocated for atom #index's position (using global index) More... | |
double * | getPositionPointer (const Atom *a) const |
get the pointer to the memory space allocated for a given atom More... | |
This is the main class of this project.
Following a nice concept, a physical model is able to represent any kind of 3D physical model that appeared, appears or will appear on earth. This include FEM meshes, spring-mass networks, phymulob etc...
|
noexcept |
Default constructor : this one just initialize everything.
Structures and atoms are empty.
PhysicalModel::PhysicalModel | ( | const char * | fileName, |
PtrToSetProgressFunction | pspf = nullptr |
||
) |
instantiate a physical model object using a XML native format file This method may throw a PMLAbortException if a problem occurs.
fileName | the name of the xml file to use |
pspf | is a pointer to the method that will be called by the setProgress(...) method (default = NULL) |
|
virtual |
destructor
bool PhysicalModel::addAtom | ( | Atom * | newA | ) |
Add a new atom to the atoms' structural component.
It does add the atom only if it has a unique index, otherwise nothing is done. (if index is correct, then it also call the addGlobalIndexAtomPair method).
References addGlobalIndexAtomPair(), and Structure::getIndex().
bool PhysicalModel::addGlobalIndexAtomPair | ( | std::GlobalIndexStructurePair | p | ) |
add or update a pair to the atom map.
It does nothing if the atom already exist in the map
Referenced by addAtom(), setAtoms(), and Atom::setIndex().
bool PhysicalModel::addGlobalIndexCellPair | ( | std::GlobalIndexStructurePair | p | ) |
add or update a pair to the cell map.
It does nothing if the cell already exist in the map
Referenced by Cell::setIndex().
void PhysicalModel::exportAnsysMesh | ( | std::string | filename | ) |
Save the mesh (atoms/cells) of this PhysicalModel in the Ansys format.
//@@ This method is useful only for a FEM (?) mesh. Maybe it's better to put it in a femPM class that inherits PhysicalModel???
References Component::getCell(), getComponentByName(), Structure::getIndex(), getNumberOfAtoms(), Component::getNumberOfCells(), StructuralComponent::getNumberOfStructures(), Atom::getPosition(), StructuralComponent::getStructure(), Structure::getType(), StructureProperties::HEXAHEDRON, StructureProperties::QUAD, StructureProperties::TETRAHEDRON, and StructureProperties::WEDGE.
Referenced by PrepWriter::write().
void PhysicalModel::exportPatran | ( | std::string | filename | ) |
Save the geometry (atoms/cells) of this PhysicalModel in the Patran format.
%%% This method is useful only for a FEM (?) mesh. Maybe it's better to put it in a femPM class that inherits PhysicalModel???
References getAtom(), Component::getCell(), getExclusiveComponent(), Structure::getIndex(), getName(), getNumberOfAtoms(), Component::getNumberOfCells(), StructuralComponent::getNumberOfStructures(), Atom::getPosition(), StructuralComponent::getStructure(), Structure::getType(), StructureProperties::HEXAHEDRON, and StructureProperties::WEDGE.
|
inline |
Get the atom that has the global index given in parameters.
The global index of an atom is the index stored as its property. This is different from its rank in the atoms list as Physical Model do not nessecarily have consecutive indexes starting at 0.
Therefore:
id | the atom index in the physical model |
References Structure::getIndex(), and StructuralComponent::getStructure().
Referenced by AtomIterator::AtomIterator(), MonitorDisplacement::calculate(), MonitorNormDisplacement::calculate(), MonitorRen::calculate(), Cell::Cell(), SofaSimulator::createPml(), exportPatran(), SurfaceExtractor::generateExternalSurface(), Facet::getCell(), PMLComponentExtension::save(), Arrows::update(), Colors::update(), and Simulator::updatePositions().
|
inline |
get all the atoms
Referenced by CreateSC::apply(), getComponentByName(), Position::Position(), SofaSimulator::SofaSimulator(), Simulator::updatePositions(), and Atom::xmlPrint().
|
inline |
get the cell that has the global index given in parameters.
id | the cell index in the physical model |
Component * PhysicalModel::getComponentByName | ( | const std::string | n | ) |
get a structural or multi component by its name.
Becareful: this method never returns a cell (only a structural component or a multiple component. To get a cell, use getStructureByName(..)
References getAtoms(), MultiComponent::getComponentByName(), and getName().
Referenced by AtomIterator::AtomIterator(), MonitorForce::calculate(), MonitorSurface::calculate(), MonitorVolume::calculate(), exportAnsysMesh(), CreateSC::getWidget(), and SofaSimulator::SofaSimulator().
Component * PhysicalModel::getExclusiveComponent | ( | const unsigned int | i | ) | const |
get an exclusive component by its index in the list
References MultiComponent::getSubComponent().
Referenced by exportPatran().
|
inline |
get all the exclusive components
Referenced by ParametersWriter::write().
Component * PhysicalModel::getInformativeComponent | ( | const unsigned int | i | ) | const |
get an informative component by its index in the list
References MultiComponent::getSubComponent().
|
inline |
get all the informative components
Referenced by CreateSC::apply(), and PMLComponentExtension::save().
|
inline |
Return the name of the physical model.
References Properties::getName().
Referenced by exportPatran(), getComponentByName(), and xmlPrint().
unsigned int PhysicalModel::getNumberOfAtoms | ( | ) | const |
get the number of atoms
Referenced by exportAnsysMesh(), exportPatran(), SofaSimulator::SofaSimulator(), Arrows::update(), and Colors::update().
unsigned int PhysicalModel::getNumberOfCells | ( | ) | const |
get the total nr of cell in the physical model (exclusive as well as informative)
References MultiComponent::getNumberOfCells().
Referenced by xmlPrint().
unsigned int PhysicalModel::getNumberOfExclusiveComponents | ( | ) | const |
get the total number of exclusive components
References MultiComponent::getNumberOfSubComponents().
unsigned int PhysicalModel::getNumberOfInformativeComponents | ( | ) | const |
get the total number of informative components
References MultiComponent::getNumberOfSubComponents().
double * PhysicalModel::getPositionPointer | ( | ) | const |
get the pointer to the memory space allocated for the atom's position.
The memory is a big block of size getNumberOfAtoms()*3*sizeof(double). The atom positions are stored in the same order as in the atoms structural component
double * PhysicalModel::getPositionPointer | ( | const Atom * | a | ) | const |
get the pointer to the memory space allocated for a given atom
References a, and StructuralComponent::getStructure().
double * PhysicalModel::getPositionPointer | ( | const unsigned int | index | ) | const |
get the pointer to the memory space allocated for atom #index's position (using global index)
References a, and StructuralComponent::getStructure().
|
inline |
get all properties (beware of what you do with them!): please consider calling setModified().
When you modify/add a property (or the physical model or any component/structure), you should always call setModified() in order to specify that something has changed.
|
inline |
get a cell using its name
|
inline |
check if something have changed
|
virtual |
Set the new position of an atom.
References Atom::setPosition().
void PhysicalModel::setAtoms | ( | StructuralComponent * | sc, |
bool | deleteOld = true |
||
) |
set the atom structural component.
Becareful: the physical model takes control of this structural component
sc | the new atom structural component |
deleteOld | if true, then the old atoms SC is delete (thus deleting its atoms as well) |
References a, addGlobalIndexAtomPair(), StructuralComponent::ATOMS, StructuralComponent::composedBy(), StructuralComponent::getNumberOfStructures(), and StructuralComponent::getStructure().
Referenced by SofaSimulator::createPml(), and PMLComponentExtension::save().
void PhysicalModel::setExclusiveComponents | ( | MultiComponent * | mc | ) |
set the exclusive multi component. Becareful: the physical model takes control of this MultiComponent
References MultiComponent::setPhysicalModel().
Referenced by SofaSimulator::createPml(), and PMLComponentExtension::save().
void PhysicalModel::setInformativeComponents | ( | MultiComponent * | mc | ) |
set the exclusive multi component. Becareful: the physical model takes control of this MultiComponent
References MultiComponent::setPhysicalModel().
Referenced by CreateSC::apply(), SofaSimulator::createPml(), and PMLComponentExtension::save().
|
inline |
tell the physical model something has changed (for example: a property was modified/added).
This can be useful to check if something has changed since the PhysicalModel was created.
|
inline |
set the name of the physical model
References Properties::setName().
Referenced by SofaSimulator::createPml().
|
virtual |
this method is called during a long process everytime a little bit of the process is finished.
This method should be overloaded by the subclass to give a mean to produce a progress bar or equivalent gui/hmi stuff.
donePercentage | the percentage (between 0 and 100) of the work already done |
void PhysicalModel::xmlPrint | ( | std::ostream & | o, |
bool | opt = false |
||
) |
print the physical model to an output stream in a XML format (see physicalmodel.xsd for detail about the XML format).
By default the output is not optimized (optimized = faster loading). In order to optimize, the cell and atom indexes are renumbered to be consecutive, so access to celli or atomi is done in linear time. There are many reasons why you would not want to optimize the output, e.g. if you have a specific cell numbering that you are using somewhere else, in a different software or so.
o | the ostream to write to |
opt | a boolean indicating if yes or no you want the pm to optimize the output |
References Properties::getField(), getName(), getNumberOfCells(), StructuralComponent::getNumberOfStructures(), MultiComponent::getNumberOfSubComponents(), Properties::getString(), Properties::numberOfFields(), MultiComponent::xmlPrint(), and StructuralComponent::xmlPrint().
Referenced by SofaSimulator::createPml(), and PMLComponentExtension::save().
|
static |
Current PML library version.