hi Alex,I am not an expert or one of the developers of the IBFE, but as far as I know, there is a method called registerInitialCoordinateMappingFunction in the IBFEmethod class that do what exactly your first question asked for, you can take a look at example ex0 in the ./examples/IBFE/explicit/ folder for more details.For your 2nd question, If I were you, i would utilize the parameter *ctx, which essentially can be anything, to encode the difference between slightly different stress functions.Best,Hong
--
You received this message because you are subscribed to a topic in the Google Groups "IBAMR Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ibamr-users/ZrLq6NiB8NE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ibamr-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ibamr-users/ed91c85b-214b-42c3-81b6-267ff033691dn%40googlegroups.com.
On Dec 7, 2020, at 8:36 PM, Alexander Hoover <hoover.a...@gmail.com> wrote:Quick follow-up (in case anybody know), is there a way internally to set *.ctx for different meshes, as opposed to setting them in CAD/your mesher?
vector<PK1StressFcnData> stress_fcn_data_vec = { … }; // set up stress functions for each partfor (int part = 0; part < num_part; ++part){ibfe_method->registerPK1StressFunction(stress_fcn_data_vec[part], part);}
void my_PK1_stress_fcn(TensorValue<double>& F,
const TensorValue<double>& FF,
const Point& x,const Point& X,Elem* elem,const vector<const vector<double>*>& system_var_data,const vector<const vector<VectorValue<double>>*>& system_grad_var_data,double data_time,void* ctx){// interpret ctx as pointer to integer:int* part_num_ptr = static_cast<int*>(ctx);// dereference the pointer to get the part number:int part_num = *part_num_ptr;/// NOTE: the foregoing could be done in one line: int part_num = *static_cast<int*>(ctx);// rest of the implementation …}
// first create a vector<int> containing the part numbers.//// because vector::push_back can move data around in memory if// it resizes the vector, we need to do this in a separate loop, because// we will ultimately pass in pointers to these data items to the// PK1 stress function specifications. Those pointers can become// invalidated if the vector is resized.for (int part = 0; part < num_part; ++part){part_num_vec.push_back(part);}// then create a vector of PK1 stress function specifications and pass its// contents to the IBFE method object.vector<PK1StressFcnData> stress_fcn_data_vec;for (int part = 0; part < num_part; ++part){// notice that we pass in a pointer to an integer that captures the part number// as the ctx here:stress_fcn_data_vec.push_back(PK1StressFcnData(my_PK1_stress_fcn, {}, &part_num_vec[part]));ibfe_method->registerPK1StressFunction(stress_fcn_data_vec[part], part);}
You received this message because you are subscribed to the Google Groups "IBAMR Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ibamr-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ibamr-users/CAA5WRaUT0VnB7iwCAmQUSoBF1PrEjESsmXggA0DwH9YaG%2B-wSA%40mail.gmail.com.
You received this message because you are subscribed to the Google Groups "IBAMR Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ibamr-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ibamr-users/1a435e2b-6da7-47ab-8bcd-c5a59f08b4c6n%40googlegroups.com.
vector<Mesh*> meshes = {&mesh1, &mesh2, &mesh3, &mesh4};
const double dx = input_db->getDouble("DX");const double ds = input_db->getDouble("MFAC")*dx;
const string mesh_filename = input_db->getStringWithDefault("MESH_FILENAME","Plate.e”);int num_parts = … ;vector<shared_ptr<Mesh>> mesh_shared_ptr_vec(num_parts);vector<Mesh> mesh_ptr_vec(num_parts);for (int part = 0; part < num_parts; ++part){mesh_shared_ptr_vec[part] = make_shared<Mesh>(init.comm(), NDIM));mesh_shared_ptr_vec[part]->read(mesh_filename);mesh_shared_ptr_vec[part]->prepare_for_use();// the IBFE interface still takes in raw pointers, so we need to get it from the// shared_ptr:mesh_ptr_vec[part] = mesh_shared_ptr_vec[part].get();}
Related, If multiple copies of the mesh were acted on by the same stress function, albeit with slight differences in phase, would there be a smart way to adjust the stress function to account for multiple structures? Is this better accomplished with a geometry file that includes all of the same structures in their initial position?voidstress_function(TensorValue<double>& PP,const TensorValue<double>& FF,const libMesh::Point& X,const libMesh::Point& s,Elem* const /*elem*/,const std::vector<const std::vector<double>*>& /*var_data*/,const std::vector<const std::vector<VectorValue<double> >*>& /*grad_var_data*/,double time,void* /*ctx*/){Thank you for any and all help.
for (int part = 0; part < num_parts; ++part){Mesh* mesh = mesh_ptr_vec[part];for (auto& elem : mesh->element_ptr_range()){elem->sudomain_id() = part;}}
void my_PK1_stress_fcn(TensorValue<double>& F,
const TensorValue<double>& FF,
const Point& x,const Point& X,Elem* elem,const vector<const vector<double>*>& system_var_data,const vector<const vector<VectorValue<double>>*>& system_grad_var_data,double data_time,void* ctx){
int part_num = elem->subdomain_id();
// rest of the implementation …}
-Alex--
You received this message because you are subscribed to the Google Groups "IBAMR Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ibamr-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ibamr-users/c21504df-4a72-4636-b673-fdd944470bf2n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ibamr-users/F9746A4E-45C5-415B-A9FD-F76E2D35BB64%40gmail.com.
On Dec 8, 2020, at 10:44 AM, Alexander Hoover <hoover.a...@gmail.com> wrote:Thanks Boyce. This is all super helpful.Just for context, my goal was to1. Upload a number of copies of an identical mesh2. Space them out within the domain4. Apply a stress function that is identical for the meshes, with a slight difference in phase among them based on their location.I think the best route may be to set the location of the copies in a mesher, and then account for the differences in phase with Elem. Is there an example that uses the subdomain ID?
To view this discussion on the web visit https://groups.google.com/d/msgid/ibamr-users/CAA5WRaWuucJZvtmhGhc1VqK8Ccj_j6T6Zxdvt6vNJwodcJbaGg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ibamr-users/644883FF-4068-407F-9575-EF78B2E780EB%40gmail.com.
On Dec 8, 2020, at 11:01 AM, Alexander Hoover <hoover.a...@gmail.com> wrote:I should be able to figure it out from here Just to confirm, are elem ID the integers starting from 0? So that I could do a call something along the lines:if(elem==0){phase=...}
To view this discussion on the web visit https://groups.google.com/d/msgid/ibamr-users/CAA5WRaXx9XreJs9HwBmEA99Z%2BXG%3D7fiiSw6RFL5OYgfiRWq%3DrA%40mail.gmail.com.
main.C:359:35: error: ‘class libMesh::Mesh’ has no member named ‘element_ptr_range’
for (auto& elem : mesh->element_ptr_range())
To view this discussion on the web visit https://groups.google.com/d/msgid/ibamr-users/1009333A-ADBE-40E6-98BF-14697A3137A0%40gmail.com.
On Dec 11, 2020, at 11:43 AM, Alexander Hoover <hoover.a...@gmail.com> wrote:Following up. I've been following the elem path detailed previously, but I ran into an error with libmesh (which may be an older version)main.C:359:35: error: ‘class libMesh::Mesh’ has no member named ‘element_ptr_range’for (auto& elem : mesh->element_ptr_range())Otherwise, I've had no issues.
To view this discussion on the web visit https://groups.google.com/d/msgid/ibamr-users/CAA5WRaUQBN-LCQ%3Dwedre_PkEb7uiL2eB4PQrqn5b%2BGMpJRy-Yw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ibamr-users/7A87190C-D279-46BA-9266-27D2D13F1F2E%40gmail.com.
Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range
Any insight about what's the source?
main.C:393:291: error: no matching function for call to ‘IBAMR::IBFEMethod::IBFEMethod(const char [11], SAMRAI::tbox::Pointer<SAMRAI::tbox::Database>, std::vector<libMesh::Mesh*>&, int, bool, const string&, const int&)’
Pointer<IBFEMethod> ib_method_ops = new IBFEMethod("IBFEMethod", app_initializer->getComponentDatabase("IBFEMethod"),meshes, app_initializer->getComponentDatabase("GriddingAlgorithm")->getInteger("max_levels"),/*register_for_restart*/ true, restart_read_dirname, restart_restore_num);
The second is during the Exodus call
std::unique_ptr<ExodusII_IO> mesh1_exodus_io(uses_exodus ? new ExodusII_IO(meshes[0]) : NULL);
main.C:512:93: error: no matching function for call to ‘libMesh::ExodusII_IO::ExodusII_IO(libMesh::Mesh*&)’
std::unique_ptr<ExodusII_IO> mesh1_exodus_io(uses_exodus ? new ExodusII_IO(meshes[0]) : NULL);
The second is during the Exodus call. Looking at the examples, I noted that MeshBase was used for vectors of meshes, while Mesh is used for cases where only one mesh is present.
Thank you for all the help so far.
On Dec 11, 2020, at 6:56 PM, Alexander Hoover <hoover.a...@gmail.com> wrote:Disregard my previous two emails. I decided to upgrade to a more recent version (0.6.0). However, I'm seeking a little clarity following the path delineated previously, particularly with regards MeshBase and Mesh. I inputted the mesh in a manner similar to what had been suggested (though with some variance with respect to Mesh and MeshBase):const string mesh_filename = input_db->getStringWithDefault("MESH_FILENAME","Plate.e");
int num_parts = 4;
vector<shared_ptr<MeshBase>> mesh_shared_ptr_vec(num_parts);
vector<MeshBase*> meshes(num_parts);
for (int part = 0; part < num_parts; ++part)
{
mesh_shared_ptr_vec[part] = make_shared<Mesh>(init.comm(), NDIM);
mesh_shared_ptr_vec[part]->read(mesh_filename);
mesh_shared_ptr_vec[part]->prepare_for_use();
// the IBFE interface still takes in raw pointers, so we need to get it from the
// shared_ptr:
meshes[part]= mesh_shared_ptr_vec[part].get();
}
for (int part = 0; part < num_parts; ++part)
{
MeshBase* mesh = meshes[part];
for (auto& elem : mesh->element_ptr_range())
{
elem->subdomain_id() = part;
}
}However, I get two types of error, the first is in the IBFEMethod callPointer<IBFEMethod> ib_method_ops = new IBFEMethod("IBFEMethod", app_initializer->getComponentDatabase("IBFEMethod"),meshes, app_initializer->getComponentDatabase("GriddingAlgorithm")->getInteger("max_levels"),/*register_for_restart*/ true, restart_read_dirname, restart_restore_num);
main.C:393:291: error: no matching function for call to ‘IBAMR::IBFEMethod::IBFEMethod(const char [11], SAMRAI::tbox::Pointer<SAMRAI::tbox::Database>, std::vector<libMesh::Mesh*>&, int, bool, const string&, const int&)’Pointer<IBFEMethod> ib_method_ops = new IBFEMethod("IBFEMethod", app_initializer->getComponentDatabase("IBFEMethod"),meshes, app_initializer->getComponentDatabase("GriddingAlgorithm")->getInteger("max_levels"),/*register_for_restart*/ true, restart_read_dirname, restart_restore_num);
The second is during the Exodus callstd::unique_ptr<ExodusII_IO> mesh1_exodus_io(uses_exodus ? new ExodusII_IO(meshes[0]) : NULL);main.C:512:93: error: no matching function for call to ‘libMesh::ExodusII_IO::ExodusII_IO(libMesh::Mesh*&)’std::unique_ptr<ExodusII_IO> mesh1_exodus_io(uses_exodus ? new ExodusII_IO(meshes[0]) : NULL);
The second is during the Exodus call. Looking at the examples, I noted that MeshBase was used for vectors of meshes, while Mesh is used for cases where only one mesh is present.
To view this discussion on the web visit https://groups.google.com/d/msgid/ibamr-users/CAA5WRaWhiiwSksoxhOzOnVhbkX7jFni1mND7JjCq%2BnEc_SMKjw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ibamr-users/622C0436-EB1D-4FE3-A5F4-8D19F3F3FD88%40gmail.com.
On Dec 17, 2020, at 6:14 PM, Alexander Hoover <hoover.a...@gmail.com> wrote:Just wanted to confirm that this works (setting the element id, using it in the stress function). Thank you very much everyone for the help.
To view this discussion on the web visit https://groups.google.com/d/msgid/ibamr-users/CAA5WRaXXkbJuyBfaaLond8RZ1UOLkxuResyzBmmuBTXzYteiKA%40mail.gmail.com.