GridGenerator class. More...
#include <grid_generator.h>
Public Member Functions | |
GridGenerator (const std::string &prm_section_path="", const std::string &grid_generator_function="hyper_cube", const std::string &grid_generator_arguments="0: 1: false", const std::string &output_file_name="", const bool transform_to_simplex_grid=false, const unsigned int initial_grid_refinement=0) | |
Constructor. More... | |
void | generate (Triangulation< dim, spacedim > &tria) const |
Fill a triangulation according to the parsed parameters. More... | |
void | write (const Triangulation< dim, spacedim > &tria, const std::string &filename="") const |
Write the given Triangulation to the output file specified in Output file name , or in the optional file name. More... | |
![]() | |
ParameterAcceptor (const std::string §ion_name="") | |
unsigned int | get_acceptor_id () const |
virtual | ~ParameterAcceptor () override |
virtual void | declare_parameters (ParameterHandler &prm) |
virtual void | parse_parameters (ParameterHandler &prm) |
std::string | get_section_name () const |
std::vector< std::string > | get_section_path () const |
void | add_parameter (const std::string &entry, ParameterType ¶meter, const std::string &documentation="", ParameterHandler &prm_=prm, const Patterns::PatternBase &pattern=*Patterns::Tools::Convert< ParameterType >::to_pattern()) |
void | enter_subsection (const std::string &subsection) |
void | leave_subsection () |
void | enter_my_subsection (ParameterHandler &prm) |
void | leave_my_subsection (ParameterHandler &prm) |
void | serialize (Archive &ar, const unsigned int version) |
void | subscribe (std::atomic< bool > *const validity, const std::string &identifier="") const |
void | unsubscribe (std::atomic< bool > *const validity, const std::string &identifier="") const |
unsigned int | n_subscriptions () const |
void | list_subscribers (StreamType &stream) const |
void | list_subscribers () const |
void | subscribe (std::atomic< bool > *const validity, const std::string &identifier="") const |
void | unsubscribe (std::atomic< bool > *const validity, const std::string &identifier="") const |
unsigned int | n_subscriptions () const |
void | list_subscribers (StreamType &stream) const |
void | list_subscribers () const |
![]() | |
Subscriptor () | |
Subscriptor (const Subscriptor &) | |
Subscriptor (Subscriptor &&) noexcept | |
virtual | ~Subscriptor () |
Subscriptor & | operator= (const Subscriptor &) |
Subscriptor & | operator= (Subscriptor &&) noexcept |
void | serialize (Archive &ar, const unsigned int version) |
void | subscribe (std::atomic< bool > *const validity, const std::string &identifier="") const |
void | unsubscribe (std::atomic< bool > *const validity, const std::string &identifier="") const |
unsigned int | n_subscriptions () const |
void | list_subscribers (StreamType &stream) const |
void | list_subscribers () const |
void | subscribe (std::atomic< bool > *const validity, const std::string &identifier="") const |
void | unsubscribe (std::atomic< bool > *const validity, const std::string &identifier="") const |
unsigned int | n_subscriptions () const |
void | list_subscribers (StreamType &stream) const |
void | list_subscribers () const |
Private Attributes | |
std::string | grid_generator_function |
Name of the grid to generate. More... | |
std::string | grid_generator_arguments |
Arguments to the grid generator function. More... | |
std::string | output_file_name |
Name of the output file. More... | |
bool | transform_to_simplex_grid |
Transform quad and hex grids to simplex grids. More... | |
unsigned int | initial_grid_refinement |
Initial global refinement of the grid. More... | |
Additional Inherited Members | |
![]() | |
static void | initialize (const std::string &filename="", const std::string &output_filename="", const ParameterHandler::OutputStyle output_style_for_output_filename=ParameterHandler::Short, ParameterHandler &prm=ParameterAcceptor::prm, const ParameterHandler::OutputStyle output_style_for_filename=ParameterHandler::DefaultStyle) |
static void | initialize (std::istream &input_stream, ParameterHandler &prm=ParameterAcceptor::prm) |
static void | clear () |
static void | parse_all_parameters (ParameterHandler &prm=ParameterAcceptor::prm) |
static void | declare_all_parameters (ParameterHandler &prm=ParameterAcceptor::prm) |
static ::ExceptionBase & | ExcInUse (int arg1, std::string arg2, std::string arg3) |
static ::ExceptionBase & | ExcNoSubscriber (std::string arg1, std::string arg2) |
![]() | |
static ::ExceptionBase & | ExcInUse (int arg1, std::string arg2, std::string arg3) |
static ::ExceptionBase & | ExcNoSubscriber (std::string arg1, std::string arg2) |
![]() | |
boost::signals2::signal< void()> | declare_parameters_call_back |
boost::signals2::signal< void()> | parse_parameters_call_back |
![]() | |
static ParameterHandler | prm |
![]() | |
const std::string | section_name |
std::vector< std::string > | subsections |
GridGenerator class.
This is an interface, derived from ParameterAcceptor, for the deal.II function GridGenerator::generate_from_name_and_arguments(), for the classes GridIn and GridOut, and for the OpenCASCADE ArclengthProjectionLineManifold, NormalToMeshProjectionManifold, and NURBSPatchManifold classes.
Example usage:
This class follows the design of the ParameterAcceptor class to handle parameter files and section names.
The default set of parameters usad to drive this class is given by:
The above example allows you to generate() a hypercube with side 1, lower left corner at the origin, and with all boundary ids set to zero by default. See GridGenerator::hyper_cube() for an explanation of all the arguments.
This class understands two types of Input name
arguments:
.msh
files will be through the api version, which supports the writing of both boundary ids, material ids and manifold ids.When the Input name
argument is a function in the deal.II library, the Arguments
parameter is interpreted as a list of arguments to be passed to the function itself, and it will be passed, together with the Input name
parameter to the GridGenerator::generate_from_name_and_arguments() function.
If the argument is a filename, then the Arguments
parameter is interpreted as a map from manifold ids to CAD file names (IGES
, STEP
, and STL
formats are supported) that you can use to specify the Geometrical description of your domain (see [1] for more details of how this works in the deal.II library).
spacedim
is equal to two are fed to a NURBSPatchManifold, and can be used as a manifold for cell in two dimensions;spacedim
is equal to three are fed to a NormalToMeshProjectionManifold, and can be used as a manifold for faces or edges in three dimensions;The Output name
argument is interpreted as a file name. If the extension is understood by GridOut, then the coarse triangulation is written to this file as soon as it is generated, before any refinement occurs.
Initial grid refinement
parameter. If you want to output explicitly the refined version of the grid, you should call the write() method with the grid you want to output.If this is set to true, the class assumes you have read or generated a hex grid, and want to transform it to a simplex grid, i.e. the GridGenerator::convert_hypercube_to_simplex_mesh() is called with the grid that has been generated using Input name
and Arguments
.
In the following examples we assume that the class was instantiated with section name equal to "/". We report the example input parameter file, and show a plot of the resulting grid after refinement, i.e., we call the write() method ourselves. In order to regenerate the following examples, just place this somwhere in your code:
Parameter file :
This will generate a hyper shell with center in the point 0,0
, inner radius .5
, outer radius 1
, and with 5
cells the angular direction, colorizing the boundary ids to 0 and 1. The output grid will look like the following:
and the coarse grid (before any refinement takes place) will also be written to hyper_shell.vtk
as soon as the grid is generated.
If you later call again the write() method with another Triangulation as input parameter, then the argument of the write() method will overwrite the hyper_shell.vtk
file (or the file you specified in the parameters) with the content of the grid.
Definition at line 175 of file grid_generator.h.
ParsedTools::GridGenerator< dim, spacedim >::GridGenerator | ( | const std::string & | prm_section_path = "" , |
const std::string & | grid_generator_function = "hyper_cube" , |
||
const std::string & | grid_generator_arguments = "0: 1: false" , |
||
const std::string & | output_file_name = "" , |
||
const bool | transform_to_simplex_grid = false , |
||
const unsigned int | initial_grid_refinement = 0 |
||
) |
Constructor.
Initialize all parameters, and make sure the class is ready to run.
prm_section_path | Name of the section to use in the parameter file. |
Definition at line 40 of file grid_generator.cc.
References ParameterAcceptor::add_parameter().
void ParsedTools::GridGenerator< dim, spacedim >::generate | ( | Triangulation< dim, spacedim > & | tria | ) | const |
Fill a triangulation according to the parsed parameters.
If the output_file_name
variable is not empty, the coarse triangulation is also saved to disk in the format specified by the the output_file_format
.
Notice that the triangulation is written to disk before any initial refinement occurs. This allows you to store the Triangulation to a file, and then use the same input file you used here with the exception of the input/output grid names, and reproduce the same results.
If the triangulation would be refined before output, running the same program twice with input and output grid with the same name, would produce more and more refined grids. If you really want to output the same grid in the refined case, simply call the write() function again.
Definition at line 64 of file grid_generator.cc.
References AssertThrow, OpenCASCADE::count_elements(), deallog, StandardExceptions::ExcIO(), StandardExceptions::ExcNotImplemented(), GridGenerator::generate_from_name_and_arguments(), Triangulation< int dim, int spacedim >::load(), LogStream::pop(), LogStream::push(), GridIn< int dim, int spacedim >::read(), GridIn< int dim, int spacedim >::read_assimp(), OpenCASCADE::read_IGES(), GridIn< int dim, int spacedim >::read_msh(), OpenCASCADE::read_STEP(), OpenCASCADE::read_STL(), and Triangulation< int dim, int spacedim >::set_manifold().
Referenced by main().
void ParsedTools::GridGenerator< dim, spacedim >::write | ( | const Triangulation< dim, spacedim > & | tria, |
const std::string & | filename = "" |
||
) | const |
Write the given Triangulation to the output file specified in Output file name
, or in the optional file name.
If no Output file name
is given and filename is the empty string, this function does nothing. If an output file name is provided (either in the input file, or as an argument to this function), then this function will call the appropriate GridOut method according to the extension of the file name.
Definition at line 223 of file grid_generator.cc.
References Assert, AssertThrow, StandardExceptions::ExcIO(), StandardExceptions::ExcNotImplemented(), Triangulation< int dim, int spacedim >::save(), GridOut::set_flags(), GridOut::write_msh(), GridOut::write_ucd(), GridOut::write_vtk(), and GridOut::write_vtu().
Referenced by main().
|
private |
Name of the grid to generate.
See the documentation of GridGenerator::generate_from_name_and_arguments() for a description of how to format the input string.
If the name does not coincide with a function in the GridGenerator namespace, the name is assumed to be a file name.
Definition at line 235 of file grid_generator.h.
|
private |
Arguments to the grid generator function.
See the documentation of GridGenerator::generate_from_name_and_arguments() for a description of how to format the input string.
Definition at line 242 of file grid_generator.h.
|
private |
Name of the output file.
Definition at line 245 of file grid_generator.h.
|
private |
Transform quad and hex grids to simplex grids.
Definition at line 248 of file grid_generator.h.
|
private |
Initial global refinement of the grid.
Definition at line 251 of file grid_generator.h.