43 {
44
46
47 try {
48
49 moab::Core mb_instance;
50 moab::Interface& moab = mb_instance;
51
52 {
53 PetscBool flg = PETSC_TRUE;
56 if(flg != PETSC_TRUE) {
57 SETERRQ(PETSC_COMM_SELF,1,"*** ERROR -my_file (MESH FILE NEEDED)");
58 }
59 const char *option;
60 option = "";
62 ParallelComm* pcomm = ParallelComm::get_pcomm(&moab,
MYPCOMM_INDEX);
63 if(pcomm == NULL) pcomm = new ParallelComm(&moab,PETSC_COMM_WORLD);
64 }
65
69 bit_level0.set(0);
71
72
73 {
74
75
76 {
77
78
79
80 bool check_if_spatial_field_exist = m_field.
check_field(
"SPATIAL_POSITION");
87
88
89
91
92
94
101
102 PetscBool flg;
105 if(flg != PETSC_TRUE) {
107 }
109
110 }
111
116
121
126
131
134
135
141
143
144
145
146 if (!check_if_spatial_field_exist) {
148 ierr = m_field.
loop_dofs(
"MESH_NODE_POSITIONS", ent_method_material); CHKERRQ(
ierr);
151 }
152
153 }
154
155
156 {
164
174
175
177
179 }
180
181 }
182
183
185 {
186
187 map<int,Gel::BlockMaterialData> &material_data = gel.blockMaterialData;
188 gel.constitutiveEquationPtr = boost::shared_ptr<Gel::ConstitutiveEquation<adouble> >(
190 );
191
192
193 material_data[0].gAlpha = 1;
194 material_data[0].vAlpha = 0.3;
195 material_data[0].gBeta = 1;
196 material_data[0].vBeta = 0.3;
197 material_data[0].gBetaHat = 1;
198 material_data[0].vBetaHat = 0.3;
199 material_data[0].oMega = 1;
200 material_data[0].vIscosity = 1;
201 material_data[0].pErmeability = 2.;
202
203 int def_block = 0;
205 rval = moab.tag_get_handle(
206 "BLOCK_ID",1,MB_TYPE_INTEGER,th_block_id,MB_TAG_CREAT|MB_TAG_SPARSE,&def_block
208
212 common_data.
muName =
"CHEMICAL_LOAD";
213 common_data.
muNameDot =
"CHEMICAL_LOAD_DOT";
216
217 Gel::GelFE *fe_ptr[] = { &gel.feRhs, &gel.feLhs };
218 for(int ss = 0;ss<2;ss++) {
224 }
225
226
227 vector<int> tags;
228 tags.push_back(1);
229 tags.push_back(2);
230 tags.push_back(3);
231 tags.push_back(4);
232
233
235 new Gel::OpJacobian(
"SPATIAL_POSITION", tags,gel.constitutiveEquationPtr,gel.commonData,
true,
false)
236 );
237 gel.feRhs.getOpPtrVector().push_back(
239 );
240 gel.feRhs.getOpPtrVector().push_back(
242 );
243 gel.feRhs.getOpPtrVector().push_back(
245 );
246 gel.feRhs.getOpPtrVector().push_back(
248 );
249
250 gel.feLhs.getOpPtrVector().push_back(
251 new Gel::OpJacobian(
"SPATIAL_POSITION",tags,gel.constitutiveEquationPtr,gel.commonData,
false,
true)
252 );
253 gel.feLhs.getOpPtrVector().push_back(
255 );
256 gel.feLhs.getOpPtrVector().push_back(
258 );
259 gel.feLhs.getOpPtrVector().push_back(
261 );
262 gel.feLhs.getOpPtrVector().push_back(
264 );
265 gel.feLhs.getOpPtrVector().push_back(
267 );
268 gel.feLhs.getOpPtrVector().push_back(
270 );
271 gel.feLhs.getOpPtrVector().push_back(
273 );
274
275 }
276
277
278 DM dm;
279 DMType dm_name = "DMGEL";
280 {
282 ierr = DMCreate(PETSC_COMM_WORLD,&dm);CHKERRQ(
ierr);
283 ierr = DMSetType(dm,dm_name);CHKERRQ(
ierr);
285 ierr = DMSetFromOptions(dm); CHKERRQ(
ierr);
286
289 }
290
291
294 {
299 ierr = VecGhostUpdateBegin(
F,INSERT_VALUES,SCATTER_FORWARD); CHKERRQ(
ierr);
300 ierr = VecGhostUpdateEnd(
F,INSERT_VALUES,SCATTER_FORWARD); CHKERRQ(
ierr);
301 ierr = VecZeroEntries(U_t); CHKERRQ(
ierr);
302 ierr = VecGhostUpdateBegin(U_t,INSERT_VALUES,SCATTER_FORWARD); CHKERRQ(
ierr);
303 ierr = VecGhostUpdateEnd(U_t,INSERT_VALUES,SCATTER_FORWARD); CHKERRQ(
ierr);
304 ierr = MatZeroEntries(M); CHKERRQ(
ierr);
306 gel.feRhs.ts_u_t = U_t;
310 gel.feLhs.ts_a = 1.0;
313 ierr = VecAssemblyBegin(
F); CHKERRQ(
ierr);
315 ierr = MatAssemblyBegin(M,MAT_FINAL_ASSEMBLY); CHKERRQ(
ierr);
316 ierr = MatAssemblyEnd(M,MAT_FINAL_ASSEMBLY); CHKERRQ(
ierr);
317 }
318
319
320 {
321
322 PetscViewer viewer;
323 ierr = PetscViewerASCIIOpen(PETSC_COMM_WORLD,
"gel_jacobian_test.txt",&viewer); CHKERRQ(
ierr);
324 ierr = PetscViewerDestroy(&viewer); CHKERRQ(
ierr);
325
326
327
328
329 }
330
331 double mnorm;
332 ierr = MatNorm(M,NORM_1,&mnorm); CHKERRQ(
ierr);
333 ierr = PetscPrintf(PETSC_COMM_WORLD,
"mnorm = %9.8e\n",mnorm); CHKERRQ(
ierr);
334
335 if(fabs(mnorm-6.54443978e+01)>1e-6) {
337 }
338
339
340 {
342 ierr = VecDestroy(&U_t); CHKERRQ(
ierr);
343 ierr = MatDestroy(&M); CHKERRQ(
ierr);
344 ierr = DMDestroy(&dm); CHKERRQ(
ierr);
345 }
346
347 }
349
351
352 return 0;
353}
#define CATCH_ERRORS
Catch errors.
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base nme:nme847.
@ L2
field with C-1 continuity
#define MYPCOMM_INDEX
default communicator number PCOMM
#define CHKERRQ_MOAB(a)
check error code of MoAB function
@ MOFEM_ATOM_TEST_INVALID
PetscErrorCode DMMoFEMAddElement(DM dm, std::string fe_name)
add element to dm
PetscErrorCode DMMoFEMCreateMoFEM(DM dm, MoFEM::Interface *m_field_ptr, const char problem_name[], const MoFEM::BitRefLevel bit_level, const MoFEM::BitRefLevel bit_mask=MoFEM::BitRefLevel().set())
Must be called by user to set MoFEM data structures.
PetscErrorCode DMCreateMatrix_MoFEM(DM dm, Mat *M)
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
PetscErrorCode DMoFEMLoopFiniteElements(DM dm, const char fe_name[], MoFEM::FEMethod *method, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr())
Executes FEMethod for finite elements in DM.
PetscErrorCode DMCreateGlobalVector_MoFEM(DM dm, Vec *g)
DMShellSetCreateGlobalVector.
virtual MoFEMErrorCode add_finite_element(const std::string &fe_name, enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
add finite element
virtual MoFEMErrorCode build_finite_elements(int verb=DEFAULT_VERBOSITY)=0
Build finite elements.
virtual MoFEMErrorCode modify_finite_element_add_field_col(const std::string &fe_name, const std::string name_row)=0
set field col which finite element use
virtual MoFEMErrorCode add_ents_to_finite_element_by_type(const EntityHandle entities, const EntityType type, const std::string &name, const bool recursive=true)=0
add entities to finite element
virtual MoFEMErrorCode modify_finite_element_add_field_row(const std::string &fe_name, const std::string name_row)=0
set field row which finite element use
virtual MoFEMErrorCode modify_finite_element_add_field_data(const std::string &fe_name, const std::string name_field)=0
set finite element field data
virtual MoFEMErrorCode build_fields(int verb=DEFAULT_VERBOSITY)=0
virtual MoFEMErrorCode set_field_order(const EntityHandle meshset, const EntityType type, const std::string &name, const ApproximationOrder order, int verb=DEFAULT_VERBOSITY)=0
Set order approximation of the entities in the field.
virtual MoFEMErrorCode add_ents_to_field_by_type(const Range &ents, const EntityType type, const std::string &name, int verb=DEFAULT_VERBOSITY)=0
Add entities to field meshset.
virtual bool check_field(const std::string &name) const =0
check if field is in database
virtual MoFEMErrorCode loop_dofs(const Problem *problem_ptr, const std::string &field_name, RowColData rc, DofMethod &method, int lower_rank, int upper_rank, int verb=DEFAULT_VERBOSITY)=0
Make a loop over dofs.
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
PetscErrorCode PetscOptionsGetInt(PetscOptions *, const char pre[], const char name[], PetscInt *ivalue, PetscBool *set)
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
FTensor::Index< 'M', 3 > M
Common data for gel model.
string spatialPositionName
string spatialPositionNameDot
Constitutive model functions.
definition of volume element
Calculating right hand side.
Calculate internal forces for solvent flux.
Assemble internal force vector.
Implementation of Gel constitutive model.
virtual MoFEMErrorCode build_adjacencies(const Range &ents, int verb=DEFAULT_VERBOSITY)=0
build adjacencies
virtual MoFEMErrorCode add_field(const std::string name, const FieldSpace space, const FieldApproximationBase base, const FieldCoefficientsNumber nb_of_coefficients, const TagType tag_type=MB_TAG_SPARSE, const enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
Add field.
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Deprecated interface functions.
DEPRECATED MoFEMErrorCode seed_ref_level_3D(const EntityHandle meshset, const BitRefLevel &bit, int verb=-1)
seed 2D entities in the meshset and their adjacencies (only TETs adjacencies) in a particular BitRefL...
boost::ptr_deque< UserDataOperator > & getOpPtrVector()
Use to push back operator for row operator.
Projection of edge entities with one mid-node on hierarchical basis.