43 std::vector<CellPtr>& rCells,
44 const std::vector<unsigned> locationIndices,
46 double ghostCellSpringStiffness,
47 double ghostGhostSpringStiffness,
48 double ghostSpringRestLength)
50 mGhostCellSpringStiffness(ghostCellSpringStiffness),
51 mGhostGhostSpringStiffness(ghostGhostSpringStiffness),
52 mGhostSpringRestLength(ghostSpringRestLength)
54 if (!locationIndices.empty())
57 std::set<unsigned> node_indices;
58 std::set<unsigned> location_indices;
59 std::set<unsigned> ghost_node_indices;
63 node_indices.insert(this->
GetNode(i)->GetIndex());
65 for (
unsigned i=0; i<locationIndices.size(); i++)
67 location_indices.insert(locationIndices[i]);
70 std::set_difference(node_indices.begin(), node_indices.end(),
71 location_indices.begin(), location_indices.end(),
72 std::inserter(ghost_node_indices, ghost_node_indices.begin()));
153 assert(rNodeAGlobalIndex != rNodeBGlobalIndex);
154 c_vector<double, DIM> unit_difference;
155 const c_vector<double, DIM>& r_node_a_location = this->GetNode(rNodeAGlobalIndex)->rGetLocation();
156 const c_vector<double, DIM>& r_node_b_location = this->GetNode(rNodeBGlobalIndex)->rGetLocation();
159 unit_difference = this->mrMesh.GetVectorFromAtoB(r_node_a_location, r_node_b_location);
161 double distance_between_nodes = norm_2(unit_difference);
162 unit_difference /= distance_between_nodes;
164 double rest_length = 1.0;
165 double spring_stiffness = mGhostCellSpringStiffness;
166 if (this->mIsGhostNode[rNodeAGlobalIndex] && this->mIsGhostNode[rNodeBGlobalIndex])
168 rest_length = mGhostSpringRestLength;
169 spring_stiffness = mGhostGhostSpringStiffness;
172 return spring_stiffness * unit_difference * (distance_between_nodes - rest_length);
301 std::vector<c_vector<double, DIM> > drdt(this->GetNumNodes());
302 for (
unsigned i=0; i<drdt.size(); i++)
304 drdt[i] = zero_vector<double>(DIM);
312 unsigned nodeA_global_index = edge_iterator.GetNodeA()->GetIndex();
313 unsigned nodeB_global_index = edge_iterator.GetNodeB()->GetIndex();
315 c_vector<double, DIM> force = CalculateForceBetweenGhostNodes(nodeA_global_index, nodeB_global_index);
317 if (!this->mIsGhostNode[nodeA_global_index])
319 drdt[nodeB_global_index] -= force;
323 drdt[nodeA_global_index] += force;
325 if (this->mIsGhostNode[nodeB_global_index])
327 drdt[nodeB_global_index] -= force;
333 node_iter != this->mrMesh.GetNodeIteratorEnd();
336 unsigned node_index = node_iter->GetIndex();
337 if (this->mIsGhostNode[node_index])
339 node_iter->ClearAppliedForce();
340 node_iter->AddAppliedForceContribution(drdt[node_index]);
365 std::stringstream time;
366 time << num_timesteps;
368 if (this->mWriteVtkAsPoints)
374 unsigned num_vtk_cells = this->rGetMesh().GetNumNodes();
376 cell_writer_iter != this->mCellWriters.end();
380 std::vector<double> vtk_cell_data(num_vtk_cells);
384 node_iter != this->rGetMesh().GetNodeIteratorEnd();
388 unsigned node_index = node_iter->GetIndex();
391 if (this->IsGhostNode(node_index))
394 vtk_cell_data[node_index] = -1.0;
399 CellPtr p_cell = this->GetCellUsingLocationIndex(node_index);
402 vtk_cell_data[node_index] = (*cell_writer_iter)->GetCellDataForVtkOutput(p_cell,
this);
406 mesh_writer.
AddPointData((*cell_writer_iter)->GetVtkCellDataName(), vtk_cell_data);
411 std::vector<double> ghosts(num_vtk_cells);
413 node_iter != this->rGetMesh().GetNodeIteratorEnd();
416 unsigned node_index = node_iter->GetIndex();
417 ghosts[node_index] = (
double) (this->IsGhostNode(node_index));
424 *(this->mpVtkMetaFile) <<
" <DataSet timestep=\"";
425 *(this->mpVtkMetaFile) << num_timesteps;
426 *(this->mpVtkMetaFile) <<
"\" group=\"\" part=\"0\" file=\"mesh_results_";
427 *(this->mpVtkMetaFile) << num_timesteps;
428 *(this->mpVtkMetaFile) <<
".vtu\"/>\n";
430 if (this->mpVoronoiTessellation !=
nullptr)
436 unsigned num_vtk_cells = this->mpVoronoiTessellation->GetNumElements();
438 cell_writer_iter != this->mCellWriters.end();
442 std::vector<double> vtk_cell_data(num_vtk_cells);
446 elem_iter != this->mpVoronoiTessellation->GetElementIteratorEnd();
450 unsigned elem_index = elem_iter->GetIndex();
451 unsigned node_index = this->mpVoronoiTessellation->GetDelaunayNodeIndexCorrespondingToVoronoiElementIndex(elem_index);
454 if (this->IsGhostNode(node_index))
457 vtk_cell_data[elem_index] = -1.0;
462 CellPtr p_cell = this->GetCellUsingLocationIndex(node_index);
465 vtk_cell_data[elem_index] = (*cell_writer_iter)->GetCellDataForVtkOutput(p_cell,
this);
469 mesh_writer.
AddCellData((*cell_writer_iter)->GetVtkCellDataName(), vtk_cell_data);
474 std::vector<double> ghosts(num_vtk_cells);
476 elem_iter != this->mpVoronoiTessellation->GetElementIteratorEnd();
479 unsigned elem_index = elem_iter->GetIndex();
480 unsigned node_index = this->mpVoronoiTessellation->GetDelaunayNodeIndexCorrespondingToVoronoiElementIndex(elem_index);
481 ghosts[elem_index] = (
double) (this->IsGhostNode(node_index));
488 *(this->mpVtkMetaFile) <<
" <DataSet timestep=\"";
489 *(this->mpVtkMetaFile) << num_timesteps;
490 *(this->mpVtkMetaFile) <<
"\" group=\"\" part=\"0\" file=\"voronoi_results_";
491 *(this->mpVtkMetaFile) << num_timesteps;
492 *(this->mpVtkMetaFile) <<
".vtu\"/>\n";