34 #ifndef OOMPH_MESH_AS_GEOMETRIC_OBJECT_HEADER 35 #define OOMPH_MESH_AS_GEOMETRIC_OBJECT_HEADER 39 #include <oomph-lib-config.h> 66 namespace MeshAsGeomObject_Helper
75 SamplePointContainerParameters*&
76 sample_point_container_parameters_pt);
107 sample_point_container_parameters_pt)
109 Mesh_pt=sample_point_container_parameters_pt->
mesh_pt();
110 if (dynamic_cast<RefineableBinArrayParameters*>(
111 sample_point_container_parameters_pt)!=0)
115 else if (dynamic_cast<NonRefineableBinArrayParameters*>(
116 sample_point_container_parameters_pt)!=0)
120 #ifdef OOMPH_HAS_CGAL 121 else if (dynamic_cast<CGALSamplePointContainerParameters*>(
122 sample_point_container_parameters_pt)!=0)
129 throw OomphLibError(
"Wrong sample_point_container_parameters_pt",
130 OOMPH_CURRENT_FUNCTION,
131 OOMPH_EXCEPTION_LOCATION);
137 Communicator_pt=Mesh_pt->communicator_pt();
147 if(Mesh_pt->nelement()!=0)
149 dim[0] = Mesh_pt->finite_element_pt(0)->dim();
154 if(Mesh_pt->nnode()!=0)
156 dim[1] = Mesh_pt->node_pt(0)->ndim();
164 if(Mesh_pt->is_mesh_distributed())
167 if(Communicator_pt!=0)
169 int n_proc=Communicator_pt->nproc();
173 MPI_Allreduce(&dim,&dim_reduce,2,MPI_INT,
174 MPI_MAX,Communicator_pt->mpi_comm());
176 dim[0] = dim_reduce[0];
177 dim[1] = dim_reduce[1];
184 this->set_nlagrangian_and_ndim(static_cast<unsigned>(dim[0]),
185 static_cast<unsigned>(dim[1]));
189 std::set<Data*> tmp_geom_data;
193 unsigned n_sub_object = Mesh_pt->nelement();
194 Sub_geom_object_pt.resize(n_sub_object);
195 for(
unsigned e=0;
e<n_sub_object;
e++)
198 Sub_geom_object_pt[
e]=
202 if (Sub_geom_object_pt[
e]==0)
204 std::ostringstream error_message;
206 <<
"Unable to dynamic cast element: " << std::endl
207 <<
"into a FiniteElement: GeomObject representation is not possible\n";
210 OOMPH_CURRENT_FUNCTION,
211 OOMPH_EXCEPTION_LOCATION);
216 unsigned ngeom_data=Sub_geom_object_pt[
e]->ngeom_data();
217 for (
unsigned i=0;
i<ngeom_data;
i++)
219 tmp_geom_data.insert(Sub_geom_object_pt[
e]->geom_data_pt(
i));
224 unsigned ngeom=tmp_geom_data.size();
225 Geom_data_pt.resize(ngeom);
226 typedef std::set<Data*>::iterator IT;
228 for (IT it=tmp_geom_data.begin();it!=tmp_geom_data.end();it++)
230 Geom_data_pt[count]=*it;
235 switch (Sample_point_container_version)
239 Sample_point_container_pt=
new RefineableBinArray(sample_point_container_parameters_pt);
247 #ifdef OOMPH_HAS_CGAL 258 oomph_info <<
"Sample_point_container_version = " 259 << Sample_point_container_version << std::endl;
261 OOMPH_CURRENT_FUNCTION,
262 OOMPH_EXCEPTION_LOCATION);
295 return Sample_point_container_pt;
301 return Sub_geom_object_pt[
e];
309 return Sample_point_container_version;
315 return Sub_geom_object_pt.size();
325 mesh_pt,sample_point_container_parameters_pt);
328 build_it(sample_point_container_parameters_pt);
329 delete sample_point_container_parameters_pt;
335 sample_point_container_parameters_pt)
338 build_it(sample_point_container_parameters_pt);
347 delete Sample_point_container_pt;
382 const bool& use_coordinate_as_initial_guess =
false)
385 if (use_coordinate_as_initial_guess)
388 "Ignoring the use_coordinate_as_initial_guess argument.",
389 "MeshAsGeomObject::locate_zeta()",
390 OOMPH_EXCEPTION_LOCATION);
396 Sample_point_container_pt->
locate_zeta(zeta,sub_geom_object_pt,s);
408 position(t, zeta, r);
422 const unsigned n_lagrangian = this->nlagrangian();
427 const_cast<MeshAsGeomObject*
>(
this)->locate_zeta(zeta, sub_geom_object_pt, s);
428 if (sub_geom_object_pt == 0)
430 std::ostringstream error_message;
431 error_message <<
"Cannot locate zeta ";
432 for (
unsigned i = 0;
i < n_lagrangian;
i++)
434 error_message << zeta[
i] <<
" ";
436 error_message << std::endl;
437 Mesh_pt->
output(
"most_recent_mesh.dat");
439 OOMPH_CURRENT_FUNCTION,
440 OOMPH_EXCEPTION_LOCATION);
443 sub_geom_object_pt->
position(t, s, r);
451 OOMPH_CURRENT_FUNCTION,
452 OOMPH_EXCEPTION_LOCATION);
void broken_copy(const std::string &class_name)
Issue error message and terminate execution.
MeshAsGeomObject(Mesh *const &mesh_pt)
Constructor.
Mesh * Mesh_pt
Pointer to mesh.
SamplePointContainer * sample_point_container_pt() const
Pointer to the sample point container.
Helper object for dealing with the parameters used for the SamplePointContainer objects.
void create_sample_point_container_parameters(Mesh *mesh_pt, SamplePointContainerParameters *&sample_point_container_parameters_pt)
"Factory" for SamplePointContainerParameters of the right type as selected by Default_sample_point_co...
void operator=(const MeshAsGeomObject &)
Broken assignment operator.
FiniteElement * finite_element_pt(const unsigned &e)
Return pointer to e-th finite element.
A general Finite Element class.
RefineableBinArray class.
virtual void locate_zeta(const Vector< double > &zeta, GeomObject *&sub_geom_object_pt, Vector< double > &s)=0
Find sub-GeomObject (finite element) and the local coordinate s within it that contains point with gl...
SamplePointContainer * Sample_point_container_pt
Pointer to the sample point container.
CGAL-based SamplePointContainer.
void locate_zeta(const Vector< double > &zeta, GeomObject *&sub_geom_object_pt, Vector< double > &s, const bool &use_coordinate_as_initial_guess=false)
Find the sub geometric object and local coordinate therein that corresponds to the intrinsic coordina...
virtual void position(const Vector< double > &zeta, Vector< double > &r) const =0
Parametrised position on object at current time: r(zeta).
MeshAsGeomObject(const MeshAsGeomObject &)
Broken copy constructor.
void output(std::ostream &outfile)
Output for all elements.
MeshAsGeomObject()
Empty Constructor.
unsigned ngeom_data() const
How many items of Data does the shape of the object depend on?
OomphCommunicator * Communicator_pt
Communicator.
void position(const Vector< double > &zeta, Vector< double > &r) const
Return the position as a function of the intrinsic coordinate zeta. This provides an (expensive!) def...
unsigned Default_sample_point_container_version
Default sample point container type. Must currently be one of UseCGALSamplePointContainer, UseRefineableBinArray or UseNonRefineableBinArray.
Data * geom_data_pt(const unsigned &j)
Return pointer to the j-th Data item that the object's shape depends on.
A class that represents a collection of data; each Data object may contain many different individual ...
~MeshAsGeomObject()
Destructor.
Vector< Data * > Geom_data_pt
Vector of pointers to Data items that affects the object's shape.
void build_it(SamplePointContainerParameters *sample_point_container_parameters_pt)
Helper function to actually build the thing.
void broken_assign(const std::string &class_name)
Issue error message and terminate execution.
Vector< FiniteElement * > Sub_geom_object_pt
Internal storage for the elements that constitute the object.
NonRefineableBinArray class.
void dposition(const Vector< double > &xi, DenseMatrix< double > &drdxi) const
Return the derivative of the position.
MeshAsGeomObject(SamplePointContainerParameters *sample_point_container_parameters_pt)
Constructor.
unsigned Sample_point_container_version
Which version of the sample point container are we using?
void position(const unsigned &t, const Vector< double > &zeta, Vector< double > &r) const
Parametrised position on object: r(zeta). Evaluated at previous timestep. t=0: current time; t>0: pre...
Base class for all sample point containers.
unsigned sample_point_container_version() const
Which sample point container is used in locate zeta? (uses enum Sample_Point_Container_Type) ...
unsigned nelement()
Number of elements in the underlying mesh.
Mesh * mesh_pt() const
Pointer to mesh from whose FiniteElements sample points are created.
An oomph-lib wrapper to the MPI_Comm communicator object. Just contains an MPI_Comm object (which is ...